YAML ↔ JSON Converter
Convert between YAML and JSON, in either direction. Runs entirely in your browser.
How the conversion works
Choose a direction, paste text or upload a .yaml, .yml or .json file, then press Convert. YAML is parsed with the js-yaml library and written as indented JSON; JSON is parsed with the browser's built-in parser and written as YAML. The result can be copied or downloaded, for example as config-converted.json.
Example
A YAML value marked with an anchor (&name) and reused elsewhere with an alias (*name) is expanded during conversion, so every alias appears as a full copy in the JSON — JSON has no way to point back to an earlier value.
Things that trip people up
Only one YAML document is accepted at a time — a file with several documents separated by --- shows an error, as does empty or comment-only input. A value such as 01234 becomes the number 1234, so quote it ("01234") to keep a leading zero, for example in ZIP codes. Words such as yes, no and on stay text and are not turned into true or false.
A worked example
The YAML name: Alice, age: 30 and a tags list of admin and user becomes a JSON object with name as a string, age as the number 30 and tags as an array of two strings, indented by two spaces. Pasting that JSON back converts it to the same YAML, with the list shown as dash-prefixed lines.
How values are typed
Numbers are read by their form: 0x1F becomes 31, 0o17 becomes 15, 1e3 becomes 1000 and 01234 becomes 1234. A tilde or an empty value becomes null. A date such as 2026-01-15 stays a string rather than a date object, and quoted values always stay text. When in doubt, quote it.
JSON to YAML output
Key order is kept. Text that YAML would otherwise read as another type is quoted, so the string "123" is written '123', the string yes is written 'yes', and even a key named n is quoted. Multi-line strings become block text, and long strings are folded across lines at about 80 characters, which changes the layout only, not the value. An empty object is written as , and a plain JSON string or array gives a one-value or dash-list document.
Errors
JSON must be strict: single quotes and trailing commas are rejected with an error that points to the position. YAML errors, such as bad indentation or an unclosed bracket, show the parser's message. Comments cannot survive either direction because JSON has none.
Guide
- JSON Parse Errors: Common Mistakes and Fixes — The mistakes behind most "invalid JSON" errors, with before-and-after fixes and how to read where the parser gave up.
Frequently asked questions
Does this preserve comments in YAML?
No — comments and formatting aren't preserved when converting YAML to JSON, since JSON has no concept of comments.
Why are some keys and values quoted in the YAML output?
The writer quotes text that a YAML reader would otherwise interpret as a number, boolean or null, such as '123', 'yes' or the key 'n'. The quotes keep the type unchanged when the YAML is read again.
Why did a long string turn into a folded block?
Long text is wrapped at about 80 characters using YAML's folded style. It reads back as the same single-line value, so only the layout differs.
Are dates converted to date values?
No. A date like 2026-01-15 stays a string in the JSON. JSON has no date type, so dates are always text.