JSON YAML
Convert JSON to the YAML subset this page writes, or convert that subset back to JSON.
About this tool
JSON becomes mappings, lists, and scalars in that subset. YAML from the same subset becomes JSON. A construct outside the subset stops the conversion instead of being skipped.
The YAML formatter reprints YAML. It does not turn YAML into JSON. This page is the one that changes the language.
How to use it
- Paste JSON or YAML from the supported subset.
- Choose the direction.
- Convert. Anchors, tags, and merge keys are rejected.
Limitations
- The YAML side is the subset this page reads and writes. It is not all of YAML 1.2.
- Anchors, tags, and merge keys fail on purpose.
One value, two spellings, comments lost
Direction is a switch, and both directions drop comments
JSON to YAML parses JSON and dumps the value with a two-space indent and wrapping disabled, so a long string stays on one line. YAML to JSON loads one YAML document and prints JSON with a two-space indent. Comments exist in neither loaded value, so they vanish in both directions. A stream of two YAML documents fails, because the loader expects one. A tab at the start of a YAML line fails. JSON has no indent-by-tab issue on the way in, but the YAML it produces uses spaces.
The mismatch is the type set. JSON offers objects, arrays, strings, numbers, booleans, and null. YAML load can also build dates and can resolve anchors. A timestamp written as a calendar date can come back in JSON as a UTC instant string at midnight, not as the original characters. A zero-padded number can come back as a number whose spelling has no leading zero. An empty YAML key becomes null, and a JSON null dumped to YAML is the word null. Anchors are expanded by the load, so the alias is copied into JSON and the anchor name is gone. Dumping JSON never creates an anchor, because JSON has no shared references.
Keys and duplicates
JSON parse keeps one value for a repeated key. The YAML will not show the discarded twin. YAML merge keys are applied as far as the loader applies them, and the printed JSON contains the merged mapping rather than the merge syntax. Block scalars and quoted scalars that denoted the same string become one JSON string. The original quote style is not a JSON feature.
When to stay in one format
Use the switch to move a value you are willing to see reprinted. Keep the source if you need comments, anchor names, or the original spelling of a number or a timestamp. The YAML formatter is the page that reprints YAML with an indent of two or four and still goes through a load and a dump. This page is the one that crosses to JSON or back. Neither applies a schema.
Privacy
Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.

