YAML to JSON Converter
Turn YAML configs into strict JSON and see exactly where a file is broken.
How to use the YAML to JSON Converter
- Paste YAML on the left, or open or drop a .yaml or .yml file.
- Read the JSON on the right. It is rebuilt after every edit.
- For a file with several documents separated by ---, choose between an array of all documents and only the first one.
- If a line is reported, fix it in the left panel, then copy the JSON or save it as data.json.
Examples
About this tool
YAML is written for people: it allows comments, indentation instead of brackets, and shortcuts such as anchors. Programs, APIs and query tools usually want JSON. This converter reads YAML with the js-yaml parser and prints the same data as strict JSON, so a Compose file, a pipeline definition or a settings file can be handed to anything that only speaks JSON.
It follows the YAML 1.2 core rules. Numbers may be decimal, hexadecimal or octal, dates stay as text because JSON has no date type, anchors and aliases are expanded and merge keys (<<) are applied. Key order is kept exactly as written, even for numeric keys such as HTTP status codes, and whole numbers too large for JavaScript, such as 19-digit IDs, are written out digit for digit instead of being rounded.
When something is wrong, the message gives the line and column and names the usual cause: a tab used for indentation, a key that does not line up, a quote that is never closed, or a value containing a colon and a space that needs quotes. Tip: JSON cannot hold comments, so they are dropped. Keep the YAML file as the version you edit.
Frequently asked questions
What happens when a file has several documents?
A YAML stream can hold many documents, each starting after a line with three dashes. By default a single document is converted as it is, and several documents become one JSON array in the same order. You can also ask for an array every time, or keep only the first document.
Why does yes stay a string instead of becoming true?
YAML 1.2 treats only true and false as booleans. Older YAML 1.1 parsers also accept yes, no, on and off, which is how the country code NO ends up as false in some tools. If your file was written for such a parser, switch on "Read yes, no, on, off as true or false" under More options.
How are custom tags such as !Ref or !include handled?
JSON has no tags, so the tag is removed and the value under it is kept: !Ref Bucket becomes "Bucket". Nothing is fetched or included, and template short forms are not expanded into their long form.
Is the YAML uploaded for conversion?
No. Parsing takes place inside this browser tab and the file is never transmitted. That matters for YAML in particular, because deployment files often carry credentials and internal addresses.
Which YAML values have no JSON equivalent?
Infinity and not-a-number (.inf and .nan) are written as null. A mapping that uses a list or another mapping as its key gets that key written out as JSON text. An anchor that contains itself cannot be converted at all, so it is reported as an error.