YAML to JSON

YAML to JSON

Updated August 27, 2026

YAML is not JSON with comments. `NO` is false, `on` is true, and Norway's country code will disappear into a boolean if you don't quote it.

YAML is not JSON with comments. NO is false, on is true, and Norway's country code will disappear into a boolean if you don't quote it.

Paste YAML. Read the JSON. If a value you typed as a string became true, false, or null, quote it and convert again.

How to use it

  1. Quote anything that looks like a boolean, null, or number: NO, Yes, off, on, null, 1.0, 08. Country codes and IDs go in quotes. Always.
  2. Comments (# …) are dropped. JSON has nowhere to put them. If the comment was the point, don't convert.
  3. Anchors and aliases (&id, *id) get inlined. The duplicate is real data in JSON, not a reference.
  4. Tabs are illegal. Indent with spaces. A tab looks fine in the editor and blows up the parse.

When it breaks

  • Duplicate keys: last one wins, quietly. The JSON will not show you the first.
  • Multiline (| vs >): one keeps newlines, one folds them. Pick on purpose.
  • Version 1.1 vs 1.2 boolean rules differ. If NO survived, you got 1.2 or a quoted string. If it died, you got 1.1.
JSON Indent:

YAML Input

JS

JSON Output

YAML JSON

Features

  • Parses YAML then JSON.stringify: comments never survive
  • Anchors and aliases are inlined (duplicated values, no &/* left)
  • Country code NO (Norway) becomes boolean false unless quoted
  • Multi-document --- files become a JSON array of documents

Common Use Cases

  • See why a Helm values country: NO became false in JSON
  • Confirm comments you needed for humans are gone after convert
  • Expand YAML anchors before an API that only speaks JSON
  • Turn a multi-doc Kubernetes dump into a JSON array

YAML is not JSON with comments

YAML is not JSON with comments. NO is false, on is true, and Norway's country code will disappear into a boolean if you don't quote it.

Paste YAML. Read the JSON. If a value you typed as a string became true, false, or null, quote it and convert again.

Quote anything that looks like a boolean, null, or number: NO, Yes, off, on, null, 1.0, 08. Country codes and IDs go in quotes. Always. Comments (# …) are dropped. JSON has nowhere to put them. If the comment was the point, don't convert.

Anchors and aliases (&id, *id) get inlined. The duplicate is real data in JSON, not a reference. Tabs are illegal. Indent with spaces. A tab looks fine in the editor and blows up the parse.

Examples

Valid - Norway: unquoted NO becomes false
country: NO
# JSON: {"country": false}
Valid - Quoted NO stays a string
country: "NO"
# JSON: {"country": "NO"}
Valid - Comment is dropped
port: 8080  # listen port
# JSON has no comment
Valid - Anchor inlined
defaults: &def
  retries: 3
svc:
  <<: *def
# JSON: svc.retries is 3, no &def

Frequently Asked Questions

Why did NO become false?

YAML is not JSON with comments. NO is false, on is true, and Norway's country code will disappear into a boolean if you don't quote it. Quote anything that looks like a boolean, null, or number: NO, Yes, off, on, null, 1.0, 08. Country codes and IDs go in quotes. Always. If a value you typed as a string became true, false, or null, quote it and convert again.

Where did my comments and anchors go?

Comments (# …) are dropped. JSON has nowhere to put them. If the comment was the point, don't convert. Anchors and aliases (&id, *id) get inlined. The duplicate is real data in JSON, not a reference.

Why did the parse blow up on a line that looks fine?

Tabs are illegal. Indent with spaces. A tab looks fine in the editor and blows up the parse.

What about duplicate keys and multiline?

Duplicate keys: last one wins, quietly. The JSON will not show you the first. Multiline (| vs >): one keeps newlines, one folds them. Pick on purpose. Version 1.1 vs 1.2 boolean rules differ. If NO survived, you got 1.2 or a quoted string. If it died, you got 1.1.

Tips

  • Quote any scalar that looks like a boolean, null, or number but is an identifier (NO, on, 01).
  • Do not expect comments or anchors to survive a round-trip.
  • If JSON output shows false for a country field, that is Norway, not a missing value.

Common Mistakes

Duplicate keys: last one wins, quietly. The JSON will not show you the first.
Multiline (`|` vs `>`): one keeps newlines, one folds them. Pick on purpose.
Version 1.1 vs 1.2 boolean rules differ. If `NO` survived, you got 1.2 or a quoted string. If it died, you got 1.1.