Convert YAML to JSON

Paste YAML and get JSON. Errors show the line and column. Nothing leaves your browser.

Config files are often written in YAML, but scripts, APIs and tests often want JSON. This page opens in the YAML to JSON direction with a small config already converted. Mappings become objects, dashed lines become lists, and block text with a pipe becomes a string with line breaks. The YAML is read as plain data under the YAML 1.2 core rules, so yes stays the word yes, dates stay strings, and tags that build code, such as !!js/function, are refused with an error. Anchors and aliases are expanded into copies, because JSON has no way to point at another value. If the text has several documents separated by three dashes, the JSON is one list with an item for each, and a notice says so. Comments are dropped, since JSON cannot hold them. A mistake in the YAML is reported with its line and column, for example a bad indent.

How it works

  1. Paste JSON or YAML
  2. Choose the direction and the indent
  3. Copy the converted text

Frequently asked questions

Why is there an error about indentation?

YAML uses indentation to show nesting, and tabs are not allowed there. The message gives the line and column where the indent stops making sense. Use spaces and line the keys of one mapping up in the same column.

What happens to anchors and aliases?

They are expanded. A value that was written once with an anchor and used again with an alias appears in full each time in the JSON. A merge key written << is not merged and stays as a key named <<.

Can I convert a file with several documents?

Yes. Documents separated by --- become a JSON list with one item per document, and a notice shows the count. Paste a single document to get just that one.