JSON to YAML Converter

Convert JSON to YAML and YAML back to JSON in your browser — full YAML 1.2 parsing, comments and anchors handled, nothing uploaded. Free, no sign-up — runs locally in your browser.

Your work is auto-saved in this browser only, so a refresh won't lose it. Nothing is uploaded.

Why convert between JSON and YAML?

JSON and YAML describe the same data model — objects, arrays, strings, numbers, booleans and null — but they were designed for different readers. JSON is a machine interchange format: unambiguous, strict, and miserable to write by hand at any size. YAML is a human authoring format: it trades JSON's braces and quotes for indentation, and adds comments so a file can explain itself. That is why the same data keeps crossing the border. A Kubernetes manifest, a GitHub Actions workflow or a Docker Compose file is YAML because people edit it; the API it talks to, the log line it produces and the test fixture it is checked against are JSON because machines exchange them. A converter is the customs post between the two worlds, and a careful one matters: a sloppy conversion that turns the string "8080" into the number 8080, or the string "yes" into a boolean, has changed your data while claiming only to have restyled it.

How to use this tool

  1. Paste JSON or YAML into the box above (or press Load sample).
  2. Press JSON → YAML or YAML → JSON depending on the direction — the tool does not guess, because a JSON document is technically valid YAML too, and guessing would hide that.
  3. If the input is invalid, you get the parser's error with its line and column instead of a silent failure or, worse, a half-converted document.
  4. Use Copy result to take the converted document with you. Key order is preserved in both directions.

What converts cleanly — and what cannot

The shared core converts perfectly in both directions: nested objects and arrays, strings, numbers, booleans and nulls. A JSON document run through JSON → YAML → JSON comes back byte-for-byte equivalent as data (whitespace aside), and this converter is careful about the classic traps: strings that merely look like numbers or booleans are quoted in the YAML output so they re-parse as strings, and non-ASCII text passes through unescaped.

The losses all live on the YAML side, because YAML is the larger language. Comments vanish in JSON — there is no syntax to hold them. Anchors and aliases (&name / *name) are expanded into repeated plain data. Tags such as !!binary and exotic scalar styles (literal block scalars keep their content but not their style) flatten to their values. And a multi-document YAML file — several documents separated by --- — has no JSON equivalent at all; this tool converts one document and reports an error if it finds more, rather than quietly converting the first and discarding the rest.

Examples

This JSON configuration:

{"server":{"host":"example.com","port":8080,"tls":true},"routes":["/","/api","/health"]}

becomes this YAML — the same data in the shape a human would maintain:

server:
  host: example.com
  port: 8080
  tls: true
routes:
  - /
  - /api
  - /health

Run the YAML back through the other direction and you recover the original structure exactly — the only things that cannot make the return trip are comments and anchors, which JSON has no words for.

Which format should you keep?

Keep both, each where it belongs: YAML for files humans author and review (configuration, CI workflows, infrastructure definitions), JSON for anything machines exchange or validate (APIs, schemas, logs, data fixtures). If you are still deciding for a new file, our guide to JSON vs YAML walks through the differences that actually bite: YAML's significant whitespace, its many string styles, and the version traps around booleans. This converter follows YAML 1.2, the current specification.

Frequently asked questions

Is YAML a superset of JSON?

Yes. Every valid JSON document is also valid YAML, because YAML 1.2 kept JSON's flow syntax as a subset. The reverse is not true: YAML adds indentation-based structure, comments, anchors and several scalar styles that JSON cannot express. Converting YAML to JSON can therefore lose information (comments always disappear); converting JSON to YAML loses nothing.

What happens to comments when I convert YAML to JSON?

They are dropped. JSON has no comment syntax, so there is nowhere for them to go. The same applies to YAML anchors and aliases (they are expanded into plain data) and to document markers when a file holds several documents — this tool converts a single document and will tell you if the input contains more than one.

Why did my string "yes" come back as a boolean in some tools?

That is a YAML 1.1 trap: older parsers treat yes/no/on/off (in any capitalisation) as booleans. YAML 1.2 — which this converter follows — reserves only true and false for booleans, and quotes strings like "yes" on output so they survive the round trip as strings. If a value must stay a string, quote it in YAML.

Can this tool convert multi-document YAML files?

Not as one output — JSON has no multi-document concept, so each document would need its own JSON value. Split the file at its --- separators and convert the documents one at a time. The tool reports an error rather than silently converting only the first document.

Is my data uploaded to a server?

No. Parsing and serialising happen in your browser with a YAML library loaded with this page. Nothing you paste is sent anywhere — you can disconnect from the network and keep converting.

Why does the YAML output indent arrays the way it does?

Block sequences are indented under their parent key by the width you choose (2 spaces by default), the style used by Kubernetes manifests, GitHub Actions workflows and most hand-written YAML. Key order from your input is preserved in both directions.

Related tools

Related guides