Block maps and sequences
Convert JSON and YAML
YAML is easier to scan than a one-line JSON object, and JSON is what most programs parse. This page converts between them for a plain subset.
JSON to YAML quotes strings that could be read as numbers, booleans, or null, and quotes keys that are not plain identifiers. YAML to JSON accepts indented maps and sequences, plain scalars, and quoted strings. A tab, an anchor, a multiline | or > block, or a flow { } or [ ] form is rejected. Comments are recognized only when the whole line is a comment. Indentation is two spaces.
The document stays in this tab. It is not sent to a converter.
This tool runs in your browser. Turn on JavaScript to use it.
A map with a list
The JSON and the YAML below are the same data. The colon inside the string is quoted.
- JSON
- {"a":1,"b":["x","y"]}
- YAML
- a: 1 b: - x - y
How to use it
- 1Paste JSON and convert it to YAML, or the other way.
- 2If YAML is rejected, remove anchors, tabs, and flow braces.
- 3Copy the result into the file that expects that format.
Good to know
- Two-space indent.
- No anchors and no multiline blocks.
- A trailing comment on a value line is not stripped.
Questions
Why was my YAML rejected?
This page does not read anchors, tags, flow collections, or | and > blocks.
Will key order change?
JSON objects keep the order they were parsed in. YAML maps are printed in that order.
Are yes and no booleans?
On the way into JSON, the plain words true and false are booleans. yes and no stay strings when this page emits YAML.
Related tools
- Format and check JSON
JSON is a data format with strict commas, quotes, and no comments. This page parses what you paste and prints it again with an indent, or on one line.
- Convert CSV and JSON
CSV is a table in text. This page parses quotes and doubled quotes, then prints JSON, or walks a JSON array and prints CSV.
- Format XML
A long XML line is hard to read. This page indents elements by two spaces, or removes the indent. It does not try to repair a broken tag.