formatjson.pro
Validate, pretty-print or minify JSON in your browser — nothing is uploaded.

Convert JSON to YAML

Paste your JSON below and pretty-print it first so the nesting is obvious — YAML mirrors that indentation exactly. Below the tool is the rule-by-rule mapping so you can hand-convert or check a converter's output.

The mapping, one rule at a time

Every JSON object becomes a block of key: value lines indented under their parent. An array becomes a list where each item is a line starting with - . So "ports": [80, 443] becomes ports: on its own line, then - 80 and - 443 indented beneath it.

Quoting and types

YAML infers types, so 3 stays a number and false stays a boolean without quotes. Quote a string only when it could be misread as another type — e.g. "yes", "3.10", or a value with a leading @ or :. Plain words like api need no quotes.

Multi-line strings

A JSON string with \n in it is clearer in YAML as a block scalar: use key: | and put the literal lines, indented, on the following rows. That is the single biggest readability win of YAML over JSON.

FAQ

Is YAML always shorter than JSON?

Usually, because it drops braces, quotes, and commas — but deeply nested data can be harder to scan in YAML since structure is carried only by indentation.

Can every JSON file become YAML?

Yes. YAML is a superset of JSON, so any valid JSON is already valid YAML, and any JSON value has a clean block-style YAML equivalent.

What breaks most often in hand conversion?

Indentation. YAML uses spaces (never tabs) and every nesting level must be consistent, or the file will not parse.