Skip to content
YAS.SH
Developer🌐 YAS server-sideAPI availableintermediate

YAML / JSON Converter

Converts between YAML and JSON, two common configuration and data formats.

Processed by YAS · not stored
Ready to runInstant execution
All tools →
Loading tool…

What does this tool do?

Converts between YAML and JSON, two common configuration and data formats.

Why would I use it?

  • You maintain Docker/CI configs in YAML but an API needs JSON.
  • A Kubernetes manifest or Ansible file needs conversion for a script.
  • You want to check what a YAML file actually contains.

Real-life example

Input
name: yas
port: 3000
Output
{"name":"yas","port":3000}

YAML mappings become JSON objects; scalars keep their inferred types.

Input → Process → Output → Next

Input
Paste YAML or JSON.
Process
YAS parses the source and serializes the other format.
Output
The converted document, with warnings for anchors or unusual constructs.
Next action
Verify numbers and booleans converted as expected (YAML is loosely typed).

Common mistakes

  • Assuming YAML anchors/aliases survive conversion (they expand).
  • Indentation errors producing wrong nesting.
  • Forgetting that `yes`/`no` in YAML 1.1 can become booleans.

What the result means

The output is a faithful structural conversion; type inference follows YAML's rules.

Privacy & security

Your input is sent to YAS infrastructure because the tool requires server-side processing or public network queries. Input is not stored.

API

Endpoint
POST https://yas.sh/api/v1/tools/yaml-json
Request Header
Content-Type: application/json
cURL
curl -X POST "https://yas.sh/api/v1/tools/yaml-json" \
  -H "Content-Type: application/json" \
  -d '{"input":"name: Jane\nage: 30","mode":"to-json"}'
JavaScript
const res = await fetch("https://yas.sh/api/v1/tools/yaml-json", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "input": "name: Jane\nage: 30",
  "mode": "to-json"
}),
});
const data = await res.json();
Python
import requests

r = requests.post("https://yas.sh/api/v1/tools/yaml-json", json={"input":"name: Jane\nage: 30","mode":"to-json"})
data = r.json()
FieldTypeRequiredDescription
inputstringYesYAML or JSON text
modestringNo (default to-json)to-json | to-yaml
Success response
{ "result": { "name": "Jane", "age": 30 }, "mode": "to-json" }

Convert between YAML and JSON (mode: to-json | to-yaml).

Error responses
  • 400 VALIDATION_ERROR — invalid input or unsupported option.
  • 413 PAYLOAD_TOO_LARGE — input exceeds the 64 KB limit.
  • 429 RATE_LIMIT_EXCEEDED — rate limit exceeded (60 req/min).
Limits
  • Maximum input: 64 KB per request.
  • Rate limit: 60 requests/min per IP address.
  • Authenticated accounts benefit from higher tier quotas.

YAML / JSON Converter: technical reference, use cases and FAQ

How YAML / JSON Converter works

YAML is a superset of JSON, so every JSON document is already valid YAML and converting JSON to YAML is a re-serialization into block style. The other direction resolves YAML's additional features — anchors and aliases, multi-document streams, block scalars, implicit typing — down to the plain object, array, string, number, boolean and null vocabulary that JSON supports.

Implicit typing is where YAML surprises people. An unquoted scalar is type-inferred: yes, no, on and off become booleans in YAML 1.1 parsers, a bare 09 may be rejected or read as a string, and a value like 1.0 becomes a float. The Norway problem — the country code NO parsing as boolean false — is the canonical example, and it is why configuration values that must be strings should be quoted.

When to use it: real-world scenarios

Converting a Kubernetes manifest for a tool that wants JSON

kubectl accepts both, but many admission controllers, policy engines and diff tools operate on JSON. Converting keeps one source of truth in YAML.

Debugging a CI pipeline definition

GitHub Actions and GitLab CI files fail on indentation and implicit typing. Seeing the JSON equivalent shows exactly what the parser understood, which is rarely what the indentation suggested.

Flattening anchors and aliases before handing a file to another team

Anchors keep YAML DRY but make it harder to read. Converting expands them into the concrete structure they produce.

Generating YAML from an API response

Take a JSON payload and emit YAML for a config file or a documentation example, without hand-indenting nested structures.

Pro tips

  • Quote any string that could be misread as another type: version numbers, country codes, times like 22:30, and anything starting with a zero.
  • Use spaces, never tabs. The YAML specification forbids tabs for indentation and the resulting error message rarely says so plainly.
  • Block scalars control newline handling: | keeps them, > folds them, and a trailing - or + controls the final newline. Pick deliberately when embedding scripts or certificates.
  • A YAML file can contain multiple documents separated by ---. JSON cannot, so only the first document survives conversion unless you convert to an array yourself.

Limitations and edge cases

What this tool deliberately does not do, and where it will disagree with other implementations.

  • Comments are lost. YAML parsers discard them, so converting a well-documented config strips the documentation.
  • Anchors and aliases are expanded, not preserved, which can substantially increase file size.
  • Multi-document streams collapse to the first document, since JSON has no equivalent construct.
  • Non-string mapping keys and complex keys are legal in YAML but cannot be represented in JSON, where every key is a string.

Frequently asked questions

Is JSON valid YAML?
Yes. YAML 1.2 is a strict superset of JSON, so any JSON document can be parsed by a conformant YAML parser. The reverse is not true.
Why did my value 'no' become false?
YAML 1.1 implicit typing treats yes/no/on/off as booleans. Quote the value — "no" — to force a string. This bites country codes, feature flags and version fields.
Are comments preserved?
No, in either direction. Comments are not part of the parsed data model, so they cannot survive a conversion. Keep the annotated file as your source.
What happens to multiple YAML documents in one file?
Only the first is converted, because a JSON document has a single root. Split the stream and convert each document if you need all of them.
Ask YAS AI
🍪 Cookies & privacy. Essential cookies keep you signed in and remember language and theme. Google AdSense and reCAPTCHA are Google technologies: AdSense runs only after Accept All; reCAPTCHA loads on sign-in and contact forms. See how Google uses data: https://policies.google.com/technologies/partner-sites cookie policy · privacy policy.
Settings