YAML ↔ JSON

Convert between YAML and JSON.

You open a Kubernetes manifest, a GitHub Actions workflow, or a docker-compose.yml and need the same data as JSON — maybe to feed an API, maybe just to see the structure without squinting at indentation. Or the reverse: an API returned a wall of JSON and you want the readable YAML version for a config file.

This converter goes both ways. Paste into the top box, press one of the two buttons, and the result appears below, ready to copy.

How it works

The two buttons

YAML → JSON parses your YAML and prints it as JSON indented with 2 spaces. JSON → YAML does the opposite: it parses the JSON and re-emits it as YAML, also at 2-space indentation, with long lines left unwrapped so strings stay on one line instead of being folded.

Both buttons read from the same input box, so you don't need to move anything between panes — just paste once and pick a direction.

What conversion actually changes

YAML and JSON describe the same data model (maps, lists, scalars), which is why the round trip works at all. What differs is the surface:

YAMLJSON
Structureindentationbraces and brackets
Comments# supportednot supported
Quoting keysoptionalalways required
Trailing commasn/ainvalid

The practical consequence: converting YAML to JSON drops your comments. They are not part of the data, so there is nowhere for them to go. If the YAML file is a config you maintain by hand, keep the original rather than round-tripping it.

When it fails

If the input is malformed, a red message shows the parser's own error text with a line reference. Two causes account for most of them: mixing tabs with spaces in YAML (tabs are illegal as YAML indentation), and a trailing comma or single-quoted string in JSON, which are valid JavaScript but not valid JSON.

Everything runs in your browser using js-yaml — nothing is uploaded — so pasting a config with an embedded token is no riskier than opening the file locally. Even so, rotating anything you paste into a public tool is a reasonable habit.

Terms explained

YAML
A whitespace-indented data format designed to be readable by hand. Common in CI pipelines, Kubernetes, and application config.
JSON
A brace-and-bracket data format that most APIs and programming languages parse natively. Stricter than YAML about quoting and commas.
Indentation
How many spaces mark each nesting level. This tool emits 2 spaces for both formats.
Parse error
The message shown when the input doesn't match the format's grammar. It usually names the line where the parser gave up.
Anchor and alias
YAML's `&name` / `*name` syntax for reusing a block. It is expanded during conversion, so the JSON output repeats the value in full.

Frequently asked questions

Does converting YAML to JSON keep my comments?

No. Comments exist only in YAML's syntax, not in the underlying data, so JSON has no place to store them. If you need the comments, keep the original YAML file and treat the JSON as a derived artifact.

Is my data sent to a server?

No. The conversion runs in your browser with a JavaScript library, so the text in the box never leaves your device. You can confirm this by loading the page and then going offline — it still works.

Why does my YAML fail with an indentation error?

The most common cause is a tab character. YAML forbids tabs for indentation, and editors that insert them silently will produce YAML that looks fine but won't parse. Replace tabs with spaces and try again.

Can it handle multiple YAML documents in one file?

Files separated by `---` contain several documents. This tool converts a single document, so split them and convert each one separately.

Why did my JSON paste fail when it looks valid?

JSON is stricter than JavaScript object literals. Single-quoted strings, unquoted keys, trailing commas, and `//` comments are all rejected, even though many editors accept them.