YAML to JSON
Runs in your browser — your text is not sent anywhere to use this tool.
Save this tool
Keep YAML to JSON handy
Use your browser's Share menu, then “Add to Home Screen”.
Convert a config file to JSON, or JSON back to readable YAML.
- Paste your YAML, or JSON if you want to go the other way
- Pick the indentation, and whether to sort keys so two files can be compared
- Convert, then copy or download the result
About this tool
YAML is what configuration is written in and JSON is what most things read, so this conversion sits between a file a person edits and a program that consumes it. YAML is far less simple than it looks. Anchors let one block be reused elsewhere, block scalars fold or preserve line breaks depending on a single punctuation mark, implicit typing quietly turns the word no into false, and a file can hold several documents separated by three dashes. A rough parser handles most of that and fails silently on the rest, producing valid-looking JSON with the wrong values in it, so this uses a full YAML implementation instead. The part people actually need most is the error message. Nearly every YAML mistake is an indentation mistake, and indentation mistakes are noticed several lines below where they were made, so the line number is reported rather than a general complaint that something is wrong. Where a file contains multiple documents they become a JSON array and you are told, because keeping only the first would lose data without a word. Everything runs in your browser.
Frequently asked questions
Why does my YAML fail with an error several lines below the mistake?
Because indentation is the structure. A block indented one space too far is still valid until something later contradicts it, which is where the parser finally objects. Start at the reported line and read upwards to the last line whose indentation you are sure of.
What happens to a file with several documents in it?
They become a JSON array, one entry per document, and the count is shown above the result. JSON has no way to express a document separator, and keeping only the first would silently discard the rest, so the change is made visible instead.
Why did the word no become false?
That is YAML doing what it is specified to do. In YAML 1.1 the words yes, no, on and off are booleans, which surprises people with a country code or an answer field. Quote the value in your YAML if you want it to stay a string.
Why would I sort the keys?
To compare two versions of the same configuration. One written by hand and one produced by a tool will list the same settings in different orders, and a diff of the two is unreadable. Sorting both puts every key in the same place so only real differences show.
Are comments kept when I convert?
No, and they cannot be. JSON has no comment syntax, so anything after a hash is lost on the way across. Converting JSON back to YAML produces a clean file without the original comments, which is worth knowing before you overwrite the file you started with.
Help improve this tool
Found a bug, want a change, or need a tool we don't have?
You have an unsent draft.
Thanks — that's with us. You'll find the reply in your inbox.Go to my messages