Skip to content
Accessibility
Theme
Text size
High contrast
Limit animations
Readable fontAtkinson Hyperlegible
Increased text spacing
Underline links
Always show focus

Runs in your browser — nothing you paste is uploaded.

YAML ↔ JSON

Convert YAML to JSON and JSON to YAML. Handles nesting, anchors and typical config files. Runs in your browser.


    

What it does

Converts between YAML and JSON in both directions as you type. YAML → JSON parses YAML — nested maps, sequences, and anchors/aliases, which are resolved into plain values — and prints indented, two-space JSON. JSON → YAML parses the JSON and re-emits it as YAML, dropping quotes and braces where YAML allows. If either input is malformed, the parser's error message (with the line it choked on) is shown instead of a result.

How it works

Parsing is done with the js-yaml library in your browser. YAML and JSON describe the same data model — maps, lists, strings, numbers, booleans and null — so conversion is a parse into that model followed by a serialise into the other syntax. JSON is in fact a strict subset of YAML, which is why valid JSON also parses cleanly in the YAML direction.

Worked example

This YAML:

name: Ada
roles:
  - admin
  - editor

becomes { "name": "Ada", "roles": ["admin", "editor"] }. Switch mode and paste that JSON back to get the original YAML.

Gotchas

  • Comments are lost. JSON has no comment syntax, so any # comments disappear on a YAML → JSON round trip.
  • One document at a time. A YAML stream split with --- into multiple documents is not accepted — convert each document separately.
  • Indentation must be spaces. YAML forbids tabs for indentation; a stray tab produces a parse error.
  • Anchors (&x) and aliases (*x) are expanded, so the JSON contains the resolved value, not the reference.

When to use it

Reading a Kubernetes manifest, Docker Compose file, GitHub Actions workflow or any app config in whichever syntax you find easier, or feeding YAML-only config into a JSON-only tool. For pretty-printing or validating the JSON side, use JSON Formatter; for tabular data see CSV ↔ JSON, and to turn the JSON into interfaces see JSON to TypeScript & Go.

Privacy

Conversion runs locally in your browser; nothing you paste is uploaded.

Frequently asked questions

Are my YAML comments kept when converting to JSON?

No. JSON has no comment syntax, so # comments are dropped during conversion. If comments matter, keep the original YAML as your source of truth.

Can it convert a file with multiple YAML documents?

No. Input separated by --- into several documents is not supported; convert one document at a time.

Is every JSON file valid YAML?

Yes. JSON is a subset of YAML, so any valid JSON parses in the YAML → JSON direction. The reverse is not true — plenty of valid YAML uses features, such as comments, that JSON cannot represent.

Related tools