YAML to JSON Converter
Two-way YAML and JSON conversion with block indentation, flow collections, block scalars, anchors and multiple documents
About this tool
YAML is for people and JSON is for machines, and moving data between them is daily configuration work. The difficulty is that YAML has more rules than it appears: one space of indentation changes the level, | and > treat line breaks differently, yes becomes a boolean, and tabs are simply invalid. This tool implements parsing as explicit rules and, on failure, reports the line and column and points at the offending line instead of saying only that parsing failed.
What it parses
- Block structure: block mappings and sequences, mappings nested in sequences, and any depth of indentation. Misaligned keys at the same level are reported by position
- Flow collections: single-line forms such as
{a: 1, b: [2, 3]}, which may span lines and mix with block structure - Scalars: single quotes, where two single quotes mean one; double quotes with escapes such as
\t,\nand\"; plain text; integers, negatives, decimals, scientific notation,0xhexadecimal,null,~and empty values;trueandfalse - Block scalars:
|keeps line breaks and>folds them.-strips the trailing break and+keeps trailing blank lines. No escaping is applied inside the block - Anchors and references:
&namedefines,*namereuses, and the merge key<<: *basemerges common fields into the current mapping. Output expands everything into concrete values - Comments and multiple documents:
#comments and blank lines do not affect parsing.---separates documents in one file, and multi-document mode returns an array - Type tags:
!!str,!!int,!!float,!!bool,!!seqand!!mapare honored, so!!str 42produces a string
The four switches
| Option | Values | Effect |
|---|---|---|
| Indent | 2, 4 or 8 spaces, or Tab | Controls nested indentation in the output. Tab is applied literally for JSON; for YAML the tool warns that YAML requires spaces |
| JSON output | Pretty or compact | Compact puts everything on one line for config values or command line arguments |
| Strict mode | On or off | Booleans accept only true and false, so yes, no, on and off stay strings |
| Multiple documents | On or off | Splits on --- and returns an array. When off, detecting more than one document raises an error and asks you to enable it, rather than converting only the first and looking complete |
Three result panels
- Result: the converted output, ready to copy or download, with the extension following the direction
- Tree view: collapsible, with a type and entry count on each node. Clicking a row shows its node path above and copies it in one click, which beats describing the third level down in a screenshot
- Error details: line, column, the source line with a marker, and a list when there are several problems
Input
- Drop
.yml,.yaml,.jsonor.txtfiles onto the dashed area, or click to choose a file - Paste with
Ctrl+Vin the input area to convert live, or pressCtrl+Enterto force an immediate recompute - Swap direction sends the current result to the other side, which makes comparing formats back and forth easy
FAQ
- What does mapping values are not allowed here mean? Usually one of two things: indentation is deeper than the parent key without forming a valid structure, or a value contains an unquoted colon followed by a space, for example writing
note: see http: a. Quote the value; the error panel names the line and column - Can tabs be used for indentation? No. YAML allows spaces only, and a tab is reported with its position. Configure
.ymlfiles to indent with spaces in your editor - What is not implemented? Explicit keys, written as
? keyon one line and: valueon the next, raise an error with a line number instead of dropping the node. Unknown!!tags produce a warning and are read by content type. The...end marker must be followed by---, otherwise it is reported at the line - Why did
yesbecometrue? YAML 1.1 treatsyesandonas booleans, matching most parsers. Enable strict mode or quote the value to keep it a string - Are comments preserved? Not when converting to JSON, whose syntax has no comments. Converting back to YAML keeps values only, so original comments and document notes must be restored by hand
- Are anchors expanded? Yes. Aliases and merge keys become concrete content, since JSON has no references. Changing an anchor affects every node that uses it
- What happens to dates? JSON has no date type, so date and time scalars are emitted as strings without conversion to timestamps. When writing YAML, strings such as
2026-10-01or12:30:00are quoted so other parsers do not read them as dates or base-60 numbers - What if a key appears twice? The later value wins, consistent with mainstream parsers. Rename the key if both values must be kept
- Is the content uploaded? No. Parsing, generation, tree view and download run in the browser with no requests, so intranet and offline use both work
To keep formatting the JSON, use the JSON formatter; to explore deep hierarchies, use the JSON viewer; to convert to PHP config arrays, use JSON to PHP; to export tables, use JSON to CSV; to tidy JavaScript snippets in config, use the JS formatter; to compare revisions, use the text diff.