YAML to JSON Converter

Turn YAML into JSON, with anchors resolved and errors pinned to a line and column.

How to use

What it checks and how it works

The YAML is parsed with the yaml library, which implements YAML 1.2 (revision 1.2.2 of the specification) with the core schema, so true, false, null and numbers become JSON types, and a value such as yes or no stays text. Anchors and aliases are resolved, and merge keys are applied. A file with several documents separated by --- is written as a JSON array with one item per document. JSON has no comments, dates or binary type, so comments are dropped and a timestamp stays a string. Keys that are not strings, such as numbers, are written as strings.

Why is yes not converted to true?

YAML 1.2 only reads true and false as booleans. Older YAML 1.1 parsers also accepted yes, no, on and off, but the current specification does not.

What happens to comments?

They are dropped, because JSON has no comment syntax.

Can it handle a file with several YAML documents?

Yes. Documents separated by --- become items of a JSON array, in order.

Sources

Related tools

Privacy

Runs in your browser; nothing is uploaded. The interactive tool needs JavaScript.