JSON ↔ YAML Converter
Convert JSON to YAML and YAML back to JSON right in your browser. Paste either format to get clean, correctly-indented output — ideal for config files, CI pipelines, and Kubernetes manifests.
Indent
Enter data above to see the converted result here.
How to use JSON to YAML Converter
- 1
Choose a direction
Use the toggle to pick JSON to YAML or YAML to JSON. The swap button moves your result into the input so you can convert it back the other way.
- 2
Paste your data
Paste JSON or YAML into the input box. The conversion runs automatically as you type, with structure, nesting, and data types preserved.
- 3
Pick the indent
Choose a 2-space or 4-space indent to match your project's style. The output stays clean and correctly indented for either format.
- 4
Copy the result
Review the converted output and copy it to your clipboard, ready to drop into a config file, a pipeline, or your code.
From JSON to YAML: Cleaner Config Without the Footguns
YAML is a superset of JSON
Every valid JSON document is also valid YAML — that is a guarantee of the YAML specification, not a coincidence. YAML adds a more human-friendly layer on top: instead of braces and brackets, structure is expressed through indentation; instead of commas, items sit on their own lines; and unlike JSON, YAML supports comments. The result reads like an outline rather than a data dump, which is why it dominates configuration files.
Because the data models line up so closely — both have maps, sequences, strings, numbers, booleans, and null — converting between them is mechanical and lossless for the values themselves. The conversion re-expresses the same tree in a different surface syntax. The one thing that cannot survive a JSON round trip is comments, since JSON has no place to put them.
Indentation is the syntax
In YAML, whitespace is not cosmetic — it is the structure. Nesting is shown by indenting child keys further than their parent, and items at the same depth must share the same indentation. A map nested under a key becomes a set of indented lines beneath it; a list becomes lines each beginning with a dash. Get the indentation wrong and you change the meaning, not just the appearance, which is the opposite of how JSON treats whitespace.
Choose a consistent indent width — two spaces is the common default for config files, four for some house styles — and apply it everywhere. The converter emits clean, uniform indentation so you start from a correct baseline rather than hand-aligning lines.
Tabs are forbidden
This is the rule that catches almost everyone the first time. The YAML specification explicitly disallows tab characters for indentation; you must use spaces. An editor configured to insert a tab when you press the Tab key will silently produce a file that fails to parse, often with an error message that points at the wrong place because the parser only notices the structure is broken a line or two later.
If a YAML file refuses to load and the indentation looks correct, check for tabs first. Configure your editor to show whitespace or to convert tabs to spaces for YAML files. Converting from JSON sidesteps this entirely, since the generated output is space-indented from the start.
The Norway problem and other surprise booleans
Older YAML parsers interpret a startling range of bare words as booleans: not just true and false, but yes, no, on, and off in various capitalizations. The classic disaster is a list of country codes where the entry for Norway, written as the bare letters n and o, is read as the boolean false and quietly vanishes from your data. Toggle flags written as on or off can flip type the same way.
The defense is quoting. Any string that could be mistaken for a boolean, a number, a date, or null should be wrapped in quotes so the parser keeps it as text. Modern parsers built around the safe schema are stricter and far less prone to this, but the habit of quoting ambiguous scalars is worth keeping, especially for short codes, version-like strings, and anything user-supplied.
More scalar gotchas: numbers, leading zeros, and null
A few other bare values surprise people. A ZIP code or part number with a leading zero may be read as a number and lose the zero, or be interpreted as octal in some parsers. Version strings like 1.20 can be coerced to the number 1.2, dropping the trailing zero. The word null, an empty value, and a lone tilde all mean null. As with the boolean trap, the cure is the same: quote anything whose textual form matters.
Because this tool parses with the safe schema, it loads only standard data types and never constructs arbitrary objects or executes code, so pasting untrusted YAML cannot run anything. That keeps the conversion predictable: what you get back is plain maps, sequences, and scalars, with no surprise custom types smuggled in through tags.
Where YAML actually lives
YAML's readability made it the lingua franca of infrastructure and CI tooling. Docker Compose files, Kubernetes manifests, GitHub Actions and GitLab CI pipelines, Ansible playbooks, and countless application config files are all YAML. In every one of these, the comments and clean diffs that YAML allows are a real advantage when a human has to review a change to production configuration.
JSON, by contrast, remains the better fit for machine-to-machine exchange over APIs, where its strictness and the absence of whitespace sensitivity reduce ambiguity. A common pattern is to author and edit in YAML for human comfort, then convert to JSON when a tool or endpoint demands it — which is exactly why this converter runs in both directions.
Block style, flow style, and reading the output
YAML can express the same data two ways. Block style spreads maps and lists across indented lines and is what you want for readable config. Flow style uses inline braces and brackets and looks almost exactly like JSON, which is occasionally handy for short, compact values embedded in a larger document. Knowing both helps you read YAML written by other people without confusion.
When you convert here, paste the JSON, pick your indent width, and review the block-style output before dropping it into a repository. Everything happens locally in your browser, so secrets in a config file — tokens, connection strings, internal hostnames — never leave your device, which makes it safe to convert real deployment manifests rather than sanitized examples.
Frequently asked questions
What is the difference between JSON and YAML?
How do I convert JSON to YAML?
Can it convert YAML back to JSON?
Is parsing untrusted YAML safe here?
Is my data uploaded to a server?
Related tools
Keep going with these handy tools