JSON to YAML Converter
Convert JSON into clean, readable YAML. This direction is lossless, because YAML is a superset of JSON.
Your JSON
YAML output
This is the easy direction, and it is worth saying why. Since YAML 1.2, YAML is a strict superset of JSON: every valid JSON document is already a valid YAML document. Converting is therefore not a translation between data models — both languages describe the same set of values — it is purely a change of notation, from braces and quotes to indentation and bare scalars. Nothing can be lost, because there is nothing in JSON that YAML cannot express.
The reason to do it is readability and the ecosystem. Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks, OpenAPI specifications and Helm values are all conventionally YAML, and a machine-generated JSON blob has to become YAML before a human will happily review it in a pull request. Everything here runs in your browser in a Web Worker, so a values file containing internal hostnames stays on your machine.
How to use the json to yaml
- 1
Paste your JSON
Anything valid: an object, an array of objects, deeply nested configuration, an API response. Invalid JSON is reported with the position of the problem rather than being silently repaired.
- 2
Set the indentation
Two spaces is the near-universal YAML convention and what Kubernetes tooling expects. Four is available if your house style calls for it. Tabs are worth avoiding here — see the FAQ, because YAML forbids them for indentation.
- 3
Copy the YAML into your config
Copy or download the result. Because the conversion is lossless, you can paste the output into the YAML to JSON tool at any time and get your original data structure back.
What the output looks like and why
The emitter produces block-style YAML, which is the readable form people actually want:
- Objects become key-value pairs, one per line, nested by indentation rather than braces.
- Arrays become block sequences, each item on its own line behind a
-. An array of objects — the shape of everyenv:andcontainers:list in Kubernetes — comes out in exactly the layout you would have written by hand. - Strings are left unquoted when it is safe. YAML only requires quotes when a value would otherwise be misread: strings that look like numbers or booleans, strings starting with a character such as
*,&,%or@, strings containing a colon followed by a space, and the empty string. The emitter applies those rules for you, so"3.14.0"keeps its quotes and stays a string whileinfoloses its quotes and stays readable. - Multi-line strings become block scalars. A JSON string containing
\nescapes is emitted as a literal block introduced by|, so the newlines become real newlines you can read and edit. This alone often justifies the conversion for anything containing a script or a certificate. - Key order is preserved exactly as it appeared in the JSON. Nothing is sorted.
- null becomes an empty value after the colon, which is the conventional YAML form and parses back as null.
What YAML gives you that JSON cannot
Converting produces plain YAML. It does not invent the features that make hand-written YAML expressive, and it cannot, because there is nothing in the JSON to derive them from.
Comments. JSON has no comment syntax, so there is nothing to carry across. Once the file is YAML you can add them — and this is the single biggest practical reason teams keep configuration in YAML rather than JSON.
Anchors and aliases. YAML can define a block once with &name and reuse it with *name. A converter cannot infer that two identical sub-trees in your JSON were meant to be the same thing rather than coincidentally equal, so repeated structures are emitted in full. Factor them out by hand afterwards if you want the deduplication.
Multiple documents. A YAML stream can hold several documents separated by ---, which is how a single Kubernetes file holds a Deployment and a Service together. JSON has one value per document, so the output here is always one document. Concatenate them yourself with a --- separator.
Explicit tags. YAML can annotate a value with a type tag such as !!str or a custom tag. JSON carries no such information, so no tags are emitted.
The one thing to double-check
The conversion is lossless, but the next reader of your YAML may not be as careful as this emitter. YAML 1.1 parsers — which include a surprising amount of deployed tooling, notably older PyYAML setups — treat unquoted yes, no, on and off as booleans, and treat a leading-zero number as octal.
The emitter here quotes strings that would be ambiguous under the YAML 1.2 core schema. If your JSON contains the string "no" as a country code, or "0755" as a permission mask, look at how it came out and add quotes manually if the system consuming the file is a YAML 1.1 parser. It costs you five seconds and saves an incident.
Beyond that, the round trip is safe: convert to YAML, convert back, and you get the same data. The only thing that changes is which parts a human can comfortably read.
JSON to YAML FAQ
Is anything lost converting JSON to YAML?
No. YAML 1.2 is a superset of JSON, so every JSON value has a direct YAML representation. Key order, types, nesting and string contents all survive. It is the reverse direction, YAML to JSON, that loses things — comments, anchors and multi-document streams.
Can I use tabs for indentation?
YAML forbids tab characters for indentation, so choosing tabs will produce a file most parsers reject. Use two spaces, which is what essentially every YAML tool and style guide assumes.
Why are some of my strings quoted and others not?
Quotes are added only where they are needed to preserve the value: strings that would otherwise parse as numbers, booleans or null, strings with leading indicator characters, and strings containing a colon-space sequence. Everything else is left bare, which is what makes YAML pleasant to read.
Will it add comments explaining the structure?
No. There is nothing in JSON to derive comments from, and inventing them would be a fabrication. Add them yourself once the file is YAML — that is one of the main reasons to convert.
How do I produce a multi-document YAML file?
Convert each JSON document separately and join the outputs with a --- line between them. JSON has no concept of a stream of documents, so a converter cannot produce one from a single input.
