JSON ↔ YAML Converter
Convert JSON to clean block-style YAML and YAML back to JSON — nested maps and lists, quoted and plain scalars, block and flow styles — errors name the line.
YAML that reads the way a config file should, or JSON that is exactly what the YAML meant, with the strings that would be misread quoted for you and the unsupported YAML features flagged.
Example: A service object with a port list, an env map and two hosts becomes 20 lines of YAML; the version "1.2" stays quoted so it is not read as a number, and a two-line note becomes a |- block.
The same data,
two notations.
What the YAML reader accepts, how the YAML writer chooses quoting, and where the two formats do not line up.
Reading YAML
The reader is written for this page and covers the YAML that configuration files actually use: block mappings and sequences by indentation (spaces only), “- key: value” items, plain and quoted scalars with the YAML 1.2 core types (null and ~, true/false, integers, floats, .inf), one-line flow collections like [80, 443] and {cpu: 0.5}, literal | and folded > block scalars with strip/keep chomping, comments, and a leading --- marker. Anchors and aliases (&, *), tags (!!) and multi-document files are not supported: they are read as text and flagged. Errors report the line they occurred on.
Writing YAML
Output is block style with two-space indentation, sequences as “- ” items and nested maps inline after the dash. A string is written plain unless a YAML reader would take it for something else — “1.2”, “true”, “null”, an empty string, leading or trailing spaces, a colon-space, a hash — in which case it is double-quoted with JSON escapes. Strings containing line breaks become |- blocks (or | when they end with a newline). Empty arrays and objects are written [] and {}.
Where they differ
JSON has no comments, so comments are dropped going to JSON; JSON keys are always strings, so numeric-looking YAML keys become strings; NaN and infinity cannot be represented in JSON and become null. Key order is kept unless you choose to sort. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.
SOURCES
- YAML Ain’t Markup Language 1.2.2 — block and flow collections, scalar styles, comments (the subset implemented is listed on the page)
- ECMA-404 — The JSON data interchange syntax
Last reviewed 19 September 2026. How results are checked: How we verify.