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.
Keys, values, lists and nesting convert in both directions, and key order is kept. Comments do not survive, because JSON has no comments: a # comment in YAML is dropped when you convert to JSON, and JSON never had any. In JSON to YAML, strings that look like another type are quoted so they stay strings, so the text true becomes 'true' with quotes, and a key such as n is quoted because some YAML readers take it for no. Text with line breaks becomes a block with a pipe. Choose 2 or 4 spaces for the indent in either direction.
YAML is read as plain data using the YAML 1.2 core rules. Words such as yes, no and on stay text and are not turned into true or false. A date such as 2001-01-01 stays a string. A number written 0x1F is read as 31, and ~ or null is null. Numbers larger than 9,007,199,254,740,991 lose their last digits, as in any JavaScript program, and .nan or .inf become null because JSON cannot hold them. Anchors and aliases are expanded into copies. A merge key written << is not merged and comes out as an ordinary key named <<.
A YAML text can hold several documents separated by a line of three dashes. When it does, the JSON is one list with one item per document, and a notice says how many there were. A single document is converted as it is. Custom tags such as !!js/function are refused with an error, and nothing in your text is ever run. An alias chain that would expand to millions of values is stopped before the JSON is written, and so is an alias that refers to itself.
A problem is reported as Line 4, column 2 followed by a short reason, such as bad indentation of a mapping entry. The reason comes from the reader and never includes your text. JSON is checked by the same rules as the JSON formatter page: no comments, no trailing commas, double quotes only. Everything runs in this tab. The YAML code is a separate download that loads when the page opens. Up to 500,000 characters are handled, and above 100,000 the result follows your typing after a short pause.
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.
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 <<.
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.
No. JSON has no way to hold a comment, so comments are dropped when you convert YAML to JSON. Converting back will not restore them. Keep your original YAML if the comments matter.
The page reads YAML 1.2, where only true and false are booleans. Older YAML 1.1 readers treat yes, no, on and off as booleans, which is a common source of surprises, so this page leaves them as text.
Documents separated by --- become one JSON list, one item per document, and a notice tells you how many there are. If you want only one of them, paste just that document.
No. Only plain data is read. Tags such as !!js/function, which some loaders use to build functions, are rejected with an error, and the text is never evaluated.
JSON and JavaScript hold whole numbers exactly only up to 9,007,199,254,740,991. A number like 12345678901234567890 is rounded to 12345678901234567000. Keep very long IDs in quotes so they stay text.