JSON ↔ YAML Converter
Convert between JSON and YAML instantly in your browser.
About this tool
Paste JSON or YAML into either panel and get an instant conversion in the other. Supports objects, arrays, strings, numbers, booleans, and null. Choose 2- or 4-space indentation and copy the result with one click.
How to use
- 1 Step 1: Paste your JSON into the left panel — YAML appears on the right automatically.
- 2 Step 2: Or paste YAML into the right panel — JSON appears on the left.
- 3 Step 3: Choose 2 or 4 spaces for indentation using the toggle above the panels.
- 4 Step 4: Click Copy on either panel to copy the result to your clipboard.
JSON and YAML: the same data, two notations
JSON and YAML both describe the same underlying structures — objects (key/value maps), arrays (ordered lists), strings, numbers, booleans, and null. They differ only in how that structure is written on the page. JSON uses explicit braces, brackets, quotes, and commas, which makes it unambiguous for machines but noisy for humans. YAML uses indentation and dashes instead of brackets, which makes it cleaner to read and edit by hand. Because the data model is shared, converting between them is a matter of re-rendering the same tree in the other syntax, not changing what the data means. This tool converts JSON to YAML, and with the swap button, YAML back to JSON.
How the conversion works
Converting JSON to YAML happens in two steps. First the tool parses your JSON text into an in-memory data structure — this is also your validation step, because invalid JSON fails to parse and the tool shows the error. Second, it walks that structure and writes YAML: objects become key: value lines, arrays become - item lines, and nesting is expressed by indentation (2 or 4 spaces, your choice). Going the other direction, the tool parses the indentation-based YAML into the same kind of structure and serialises it back out as JSON.stringify with your chosen indent.
A key subtlety is string quoting. Most strings in YAML need no quotes, but some must be quoted to avoid being misread. The tool automatically quotes a string when it is empty, contains YAML-special characters (such as : # [ ] { } , & *), looks like a boolean or number (true, no, 42), or contains a newline. This prevents the classic bug where the value no is silently interpreted as the boolean false.
A worked example
Paste this JSON:
{ "name": "api", "ports": [80, 443], "tls": true }
With 2-space indentation the tool produces:
name: apiports: - 80 - 443tls: true
Notice the braces, brackets, quotes, and commas are gone. The object's keys become plain lines, the array becomes a dashed list indented under ports, and the boolean stays unquoted. Click swap and the YAML round-trips back to equivalent JSON.
The trap that makes YAML famous: indentation
In JSON, structure is defined by brackets, so whitespace is cosmetic. In YAML, indentation is the structure. Two spaces vs. three spaces, or a stray tab, changes which object a key belongs to. The two most common YAML mistakes are:
- Tabs instead of spaces. YAML forbids tabs for indentation. Always indent with spaces — this tool emits spaces and you should too.
- Inconsistent indent levels. Mixing 2-space and 4-space indentation in the same file breaks parsing. Pick one (the radio buttons here let you standardise) and keep it consistent.
Scope and limitations
This is a lightweight, dependency-free converter built for the common cases you meet in config files: nested objects, arrays, scalars, and the standard quoting rules. It does not implement every corner of the YAML 1.2 specification — advanced features such as anchors and aliases (&/*), explicit type tags, multi-document streams (--- separators), and multi-line block scalars (| and >) are outside its scope. For routine API payloads, Kubernetes-style manifests, and CI configuration it handles the job; for exotic YAML, validate with a full parser.
Use cases and privacy
- Config conversion. Turn a JSON settings file into the YAML many tools and CI systems prefer.
- Readability. Convert a dense JSON response to YAML to read or diff it more easily, then convert back.
- Learning. Paste familiar JSON and watch the YAML equivalent to learn the syntax mapping.
- Quick validation. Because conversion requires parsing, a successful convert confirms your JSON or YAML is well-formed.
Both directions run entirely in your browser. Your data — which often includes API keys, hostnames, or internal config — is never uploaded, so the tool works offline and keeps sensitive values on your own machine.