JSON ↔ YAML Converter

Paste JSON to get 2-space YAML, or YAML to get pretty-printed JSON. Anchors resolve into copies; comments drop going to JSON because JSON has no comment syntax. YAML 1.2 is a superset of JSON, so valid JSON already parses as YAML. Multi-document files with --- separators must be split first. Conversion stays in this tab.

JSON
YAML
Converted on this deviceNothing leaves this tab

Runs in this tab · nothing is uploaded · Verify in 10 seconds →

What the JSON ↔ YAML converter does

JSON and YAML describe the same data structures (objects, arrays, strings, numbers, booleans and null) with different syntax. This converter turns one into the other, which is handy for Kubernetes manifests, GitHub Actions workflows, docker-compose files and OpenAPI specs.

How the JSON ↔ YAML converter works

Paste into either pane and press the matching button. JSON → YAML parses with JSON.parse and serializes with the yaml library at two-space indentation. YAML → JSON parses the YAML document and pretty-prints it as JSON. Both directions run entirely in this tab.

Limits

Single-document YAML only. Split files that use --- separators before converting.

~/faq

Frequently asked questions

Is every JSON document valid YAML?

Yes, YAML 1.2 is a superset of JSON, so valid JSON already parses as YAML. The reverse is not true: YAML features like anchors, multi-line strings and comments have no direct JSON equivalent.

What happens to YAML comments when converting to JSON?

They are dropped. JSON has no comment syntax, so comments cannot survive the round trip. Anchors and aliases are resolved into the values they reference.

Why did my unquoted value change type?

YAML guesses types for unquoted scalars: yes, no, on and off can become booleans, and 007 becomes a number. Quote the value in YAML if it must stay a string.

Can I convert multi-document YAML?

This tool converts a single document. If your file contains --- separators, split it and convert each document on its own.