LocalToolkit
HomeData Converters › JSON to YAML Converter

JSON to YAML Converter

YAML output that quotes the values which would otherwise change type on the way back.

🔒 Runs in your browser. Nothing is uploaded — verify it in the network panel, or disconnect and try again.

YAML is a superset of JSON — and that is the trap

Every valid JSON document is also valid YAML, so converting JSON to YAML is always syntactically possible. The difficulty is that YAML has a richer implicit typing system, and a scalar that was an unambiguous string in JSON may be re-read as something else. Quoting is how you prevent that.

JSON valueNaive YAML outputRead back asCorrect output
"true"trueboolean true"true"
"no"noboolean false (YAML 1.1)"no"
"007"007number 7, or refused as a bad octal in YAML 1.2"007"
"1.0"1.0float"1.0"
""(nothing)null""
"2026-01-15"2026-01-15a date object in some readers"2026-01-15"
"null"nullnull"null"

The Norway problem

Under YAML 1.1 — still the default in several widely deployed libraries — the unquoted country code NO parses as the boolean false. That single mis-typing has taken down production configuration often enough to have its own name. Countries whose codes collide with booleans and nulls include NO, YE, ON and OFF in various engines. YAML 1.2 largely fixed the set, but you do not control which parser your users have, so quote anything that could be misread.

Indentation is syntax, not style

Safety: anchors, aliases and the billion laughs

YAML supports anchors (&name) and aliases (*name) that reference earlier nodes, plus merge keys. These are extremely useful for config files and extremely dangerous for untrusted input: a small document using nested aliases can expand to gigabytes of memory — the billion laughs attack. Any YAML parser fed untrusted input must use a safe loader with alias expansion disabled or bounded. JSON has no equivalent feature, which is one reason APIs prefer it.

For machine-to-machine communication, prefer JSON. Use YAML where a human edits the file — Kubernetes manifests, CI configuration, Ansible playbooks — because comments and multi-line strings matter there. The format choice should follow who writes it.

How to use it

  1. Paste JSON.
  2. Convert — strings that resemble booleans, numbers or null are quoted automatically.
  3. Check the indentation uses spaces only.
  4. Read the result back with your target parser before committing it.

Worth knowing

  • YAML 1.2 is a strict superset of JSON, so any JSON is also valid YAML.
  • In YAML 1.1 the unquoted NO parses as the boolean false — the Norway problem.
  • Tabs are illegal for indentation; only spaces are permitted.
  • Anchors and aliases enable the billion laughs memory-expansion attack.

Limitations

  • Implicit typing differs between YAML 1.1 and 1.2 parsers, so quote defensively.
  • Anchors, aliases and tags are not generated — JSON has no equivalent constructs.
  • Comment style cannot be preserved because JSON carries no comments.
  • Deeply nested output becomes hard to read and easy to mis-indent by hand.

Frequently asked questions

Is YAML better than JSON?
It is better for files humans edit, because it supports comments and readable multi-line strings. JSON is better for machine exchange, because its typing is unambiguous and it has no alias-expansion attack surface.
Why are my strings being quoted?
Because they would otherwise change type on re-reading. "true", "no", "007" and "1.0" are all quoted so they stay strings rather than silently becoming booleans, numbers or null.
Why does my YAML fail to parse?
The two usual causes are a tab used for indentation and inconsistent indentation within a block. Both produce errors that point at a line other than the one you edited.
What is the Norway problem?
Country code NO being read as the boolean false by YAML 1.1 parsers. It illustrates why implicit typing in YAML requires quoting anything ambiguous.
Related tools
YAML to JSON ConverterJSON Formatter & ValidatorJSON to XML ConverterJSON MinifierJSON to CSV ConverterCSV to JSON Converter
Keep reading
How browser-only processing worksAll Data Converters toolsEvery tool on the site