Convert YAML to JSON
Paste a YAML mapping and get JSON text, entirely in the browser. Runs in this tab. Your inputs stay in this browser.
Input
A YAML mapping of key: value lines, or one value alone. A key with nothing after its colon holds null, or a mapping or a list indented under it with spaces. Blank lines are skipped. Up to 1 MB and 50,000 lines. Anything else is refused as INVALID_YAML, and the error names the line and what was found there.
Output
Pretty JSON with two-space indent and a trailing newline, as JSON.stringify writes it. One value alone is written as that value in JSON, so hello gives "hello" and a line break. true, True and TRUE become true, and false, False and FALSE become false. null, Null, NULL, ~ and an empty value become null. A number becomes a JSON number only when JSON writes it exactly as typed, such as 42, -7 or 1.5. Everything else is text, with the quotes around it removed. Words such as yes, no, on and off, and values such as 12:30, 1_000 or 2026-09-24, stay text, as YAML 1.2 reads them. Spaces (U+0020) around a key, a value or a list item are trimmed, but not inside quotes. Nothing else is trimmed: a no-break space or any other Unicode space stays part of the text, so a no-break space alone gives a JSON string that holds it. In the JSON, a double quote or a backslash in text gets a backslash before it. Every other character is written as it is, not escaped. Keys keep the order of the document, except that keys made only of digits, with no leading zero and below 4,294,967,295, come first in ascending order. Every other key, such as -7 or 1.5, keeps its place.
Limits
- The top level is a mapping or one value, and it starts at the first column. A top level list is refused, on one line or several, and so is a list written at the same indent as its key.
- A list goes under its key, indented, with one value per item: text, a number, true, false or null. A dash with nothing after it is null. An item that holds
key: value, another list, or more lines under it is refused. - Each value fits on its line. A value that continues on the next line is refused, and so are
|and>blocks, with or without lines under them. - A number that YAML reads differently from how it is typed is refused, not changed: 007, +1, -0, 1.0, 1.50, .5, 1e3, 0x1F, 0o17, .inf, .nan, and whole numbers that would lose digits, such as 9007199254740993. A whole number from -9,007,199,254,740,991 to 9,007,199,254,740,991 is kept as typed, unless it is -0 or has a plus sign or a leading zero, as in 007. Past that range, a whole number is kept only when JSON writes the same digits.
- Keys are plain text on one line. A quoted key is refused, and so are a key with a colon in it, a key YAML reads as true, false or null, a repeated key, and the keys
__proto__and<<. A key YAML reads as a number follows the number rule and keeps its digits. - Put a space after the colon that ends a key. A line such as
a:bis refused, even alone, so quote a single value that holds a colon. A secondkey: valueon one line is refused. - Double quotes may not hold a backslash, because escapes are not read. Single quotes may, and in single quotes
''is one quote. A quote must close on its own line, with nothing but spaces after it. - No comments. Outside quotes, a
#at the start of a line, after any indent, or after a space is refused. A#with no space before it stays part of the text. - No flow style. A key, value or list item that starts with
[or{is refused, so JSON pasted on one line or several is refused. - No anchors, aliases or tags. A key, value or list item that starts with
&,*or!is refused. Inside text they are plain characters. - A key, value or list item that starts with
],}, a comma,@,%or a backquote is refused, and so is one that starts with-,?or:followed by a space or by nothing. - A line that starts with
%(a directive), and a---or...line, are refused, so a second document is too. - Indent with spaces. A tab anywhere is refused.
- A line break is LF or CRLF. Other control characters, such as a vertical tab or a form feed, are refused, and so are a byte order mark after the start, unpaired surrogates, U+FFFE and U+FFFF. One byte order mark at the very start is skipped. The core transform also refuses a carriage return with no line feed after it, but only after the line count, which counts it as a line break. A browser text box, this one included, turns one into a line feed before the core sees it.
- A key may be up to 1,024 characters, spaces before its colon included. When the line above ends in a colon or is a lone dash, the count starts at the end of that line, even when the key is not indented under it: its trailing spaces, the blank lines and the indent count too, and each line break counts as two. A character past U+FFFF, such as most emoji, counts as two.
- Up to 50,000 lines, blank lines included. A line break at the very end does not count as another line. Up to 1 MB (1,048,576 bytes).
- No JSON to YAML.
How this was made
The core transform was written by hand into the stub registry. There is no model in this factory.
Errors
Every error names the field, the rule, and shows a small valid example. The checks run in this order: empty input, size, line count, then the YAML itself. You see the first one that fails. Input is empty when it holds only spaces (U+0020) and LF or CRLF line breaks, with or without one byte order mark at the start. Any other character, even a no-break space, another Unicode space or a tab, goes on to the other checks.
Inputs not stored
This runs in your browser tab. Your inputs are not uploaded or stored. The tool sets no cookie, uses no local storage and sends no analytics about your inputs.