JSON to YAML

Converts JSON into YAML, which is what Kubernetes manifests, GitHub Actions workflows, Docker Compose files and most modern configuration formats expect. The data is identical; only the punctuation changes.

Live demo · real result from this tool
Indent

YAML

name: toolsrift-appversion: 1.4.0private: trueengines:  node: '>=20'scripts:  dev: astro dev  build: astro buildkeywords:  - tools  - offline  - privacy 

Processed on your device — nothing is uploaded.

How to use JSON to YAML

  1. Paste your JSON on the left.
  2. The YAML equivalent appears on the right as you type.
  3. Copy it, and quote any value that might be read as a boolean or a number.
  4. Indentation is two spaces per level; never replace it with tabs.
  5. Comments cannot survive a round trip — JSON has none, so converting YAML to JSON and back loses them permanently.
  6. Conversion runs in your browser; secrets in a config file are not transmitted.

YAML is a superset of JSON, which makes this safe

Every valid JSON document is already valid YAML, so the conversion is a reformatting rather than a translation — nothing needs to be approximated or dropped. Braces and brackets become indentation, quotes around keys disappear, and array elements get a leading dash. The resulting file is typically shorter and considerably easier to read and to review in a pull request, which is why configuration migrated to it.

Indentation is the syntax, so it has to be spaces

YAML uses indentation for structure, and tab characters are forbidden outright — a tab anywhere in the document is a parse error, not a style problem. Two spaces per level is the near-universal convention. Because whitespace carries meaning, a YAML file is far easier to break by accident than a JSON one: a single misaligned line changes which parent a key belongs to, and the result often parses cleanly into the wrong structure rather than failing.

The Norway problem, and other YAML surprises

YAML 1.1 treats a bare no as the boolean false, which famously turned Norway’s country code NO into false in more than one production system. Bare yes, on, off and y are booleans too. A version number written as 1.10 becomes the number 1.1, and a MAC address or a time like 22:30 can be read as a sexagesimal integer. The fix is always the same: quote any string that could be mistaken for something else. YAML 1.2 narrowed the boolean rules, but many parsers still implement 1.1.

When to keep the JSON

YAML is better to write and review; JSON is better to generate and parse. Machine-to-machine payloads, API responses and anything a program produces should stay JSON — it is unambiguous, every language parses it identically, and it has no whitespace to corrupt. Reach for YAML where a human edits the file by hand and wants comments, which JSON cannot have.

Frequently asked questions

Why convert JSON to YAML?
YAML is more human-readable than JSON, making it better for configuration files. It's used in Docker, Kubernetes, CI/CD, and many tools.
Is the YAML output valid?
Yes, the converter produces valid YAML that can be parsed by YAML libraries and tools.
Is YAML better than JSON?
For files people edit by hand, usually — it is less noisy and supports comments. For data exchanged between programs, no: JSON is unambiguous, universally supported and has no whitespace sensitivity. They are suited to different jobs rather than competing.
Why did my value change when I converted it?
YAML infers types from unquoted text. no and off become false, 1.10 becomes 1.1, 007 may become 7, and 22:30 can become an integer. Wrap anything that must stay a string in quotes.
Can I convert YAML back to JSON?
Yes — use the YAML to JSON tool. The data round-trips exactly, with one loss: any comments in the YAML disappear, because JSON has nowhere to put them.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close