YAML ⇄ JSON Converter
Convert YAML to JSON and JSON to YAML without your config files leaving the browser — no upload, no server round-trip. The YAML side understands block mappings and sequences, quoted and plain scalars with YAML 1.1 type resolution, literal (|) and folded (>) block scalars, inline flow collections, and multi-document streams separated by --- (emitted as a JSON array). Parse errors report the exact line with a caret, and constructs JSON cannot represent — anchors, aliases, custom tags — fail loudly instead of silently corrupting your data. Going the other way, the serializer quotes strings like NO, on, and 1.0 that would otherwise re-parse as booleans or numbers.
Paste YAML above — conversion runs instantly and never leaves your browser.
How to use the yaml ⇄ json converter
- Pick a direction: YAML → JSON or JSON → YAML.
- Paste your document — Kubernetes manifests, GitHub Actions workflows, and docker-compose files are typical inputs.
- For YAML → JSON, choose 2-space, 4-space, or minified output.
- Fix any reported error — the message includes the line number and a caret pointing at the offending column.
- Copy the result or download it as converted.json / converted.yaml.
The type-coercion gotcha table
These unquoted YAML scalars do not mean what they look like. Each row shows what a YAML 1.1 parser produces — and why the JSON → YAML direction of this tool quotes them defensively.
| You write | YAML 1.1 parses it as | Real-world casualty |
|---|---|---|
| country: NO | boolean false | Norway disappears from country lists |
| version: 1.20 | number 1.2 | Go/Kubernetes version pins lose a digit |
| port_map: 22:22 | string, but 22:22:22 may parse as sexagesimal in old parsers | docker-compose port mappings — always quote them |
| id: 0o777 | number 511 (octal) | file modes silently become decimal |
| debug: on | boolean true | a string flag becomes a typed boolean |
| empty: | null (not empty string) | apps crash reading .length of null |
The fix is always the same: quote anything that must stay a string. When this tool converts JSON to YAML it applies that rule mechanically — every emitted string is re-parsed in memory, and if the result is not the identical string, it gets quoted. Multi-line strings are emitted as | literal blocks (with a |- chomping indicator when the original string has no trailing newline), which keeps embedded scripts and certificates readable.
Frequently asked questions
What is the Norway problem, and how does this tool handle it?
Under YAML 1.1, the unquoted scalars no, NO, off, and on resolve to booleans — so a country list containing the ISO code NO silently becomes false. This bites both directions: parsing YAML (this tool resolves yes/no/on/off as booleans, matching most real-world parsers) and writing it (a JSON string "NO" must be quoted or it changes type on the next read). The JSON → YAML serializer here re-parses every string before emitting it; anything that would come back as a boolean, number, or null gets double quotes automatically.
Are YAML anchors, aliases, and merge keys supported?
No, deliberately. Anchors (&base), aliases (*base), and merge keys (<<:) have no JSON equivalent, and converters that silently expand or drop them produce output that diverges from what your YAML engine sees. This tool raises an explicit error naming the construct and the line, so you can inline the values before converting. Multi-document streams, by contrast, are fully supported and become a JSON array.
Why does my YAML fail with a tab-indentation error?
The YAML spec forbids tabs in indentation because tab width is ambiguous — a file that looks aligned in your editor could nest differently in the parser. Every conforming parser rejects it, and so does this one, with the line number. Configure your editor to insert spaces for .yaml files (two spaces is the convention used by Kubernetes and GitHub Actions).
Is the conversion lossless if I round-trip YAML → JSON → YAML?
The data is preserved; the presentation is not. Comments are discarded (JSON has no comment syntax), anchors would be rejected up front, key order is kept, and block-scalar styling may change — a folded > block comes back as a literal | block since the folding intent is lost. Also note JSON cannot represent .inf or .nan: they become null, and the tool warns when that happens.
When should I use YAML instead of JSON?
Use YAML for files humans edit and re-read: CI pipelines, Kubernetes manifests, docker-compose, application config — comments, multi-line strings, and low-noise syntax matter there. Use JSON for machine-to-machine interchange: APIs, lock files, anything parsed in hot paths. JSON parsers are faster, available everywhere, and have exactly one way to write a string, which eliminates the type-coercion ambiguities YAML carries. A common pattern is authoring in YAML and converting to JSON at build time — exactly what this tool does interactively.
What is the size limit, and is anything uploaded?
Inputs up to 1 MB are accepted, which covers virtually any hand-maintained config (a typical Kubernetes deployment manifest is under 5 KB). Nothing is uploaded — parsing and serialization run as JavaScript in your tab, so secrets in env blocks or kubeconfig files never touch a server.
Related tools
- JSON ⇄ CSV ConverterConvert JSON to CSV and CSV to JSON in your browser — nested objects flattened to dot-notation columns, delimiter options, and file download.
- XML ⇄ JSON ConverterConvert XML to JSON and JSON back to XML in your browser — attribute handling, repeated elements as arrays, and clear parse error messages.
- YAML Validator / LinterValidate YAML in your browser with line-numbered errors — catch indentation mistakes, tabs, and duplicate keys in Kubernetes and CI configs.
- PX ⇄ REM ConverterConvert px to rem and rem to px instantly with any root font size — plus a full conversion table and CSS tips for accessible font sizing.
- Cups ⇄ Grams Converter (by Ingredient)Convert cups to grams by ingredient — flour, sugar, butter, rice, and 40+ more — with US and metric cup sizes and tablespoon equivalents.
- Gaj ⇄ Square Feet ConverterConvert gaj to square feet and square feet to gaj — 1 gaj = 9 sq ft — with plot-size tables for 50, 100, and 200 gaj and square yard equivalents.