JSON ↔ YAML Converter
Convert between JSON and YAML formats instantly.
JSON ↔ YAML Converter — What It Does
Paste JSON to get equivalent YAML output, or paste YAML to get clean JSON. The conversion is bidirectional and instant. Useful for preparing Kubernetes manifests, Docker Compose files, GitHub Actions workflows, and other DevOps configurations — or converting API JSON responses into YAML for config files. All processing runs in your browser.
JSON vs YAML — Side-by-Side
JSON
{
"name": "Alice",
"age": 30,
"tags": ["admin", "user"]
} YAML
name: Alice age: 30 tags: - admin - user
When to Use Each Format
- JSON — REST APIs, browser storage (localStorage), package.json, tsconfig.json, machine-generated data
- YAML — Docker Compose, Kubernetes, GitHub Actions, Ansible, Helm charts, human-edited config files
YAML Pitfalls to Watch Out For
- No tabs allowed — YAML indentation must use spaces only. Tabs cause parse errors.
- Unquoted booleans —
yes,no,on,offare parsed as booleans in YAML 1.1. Use quotes if you mean the literal string. - Colon in strings — A string like
url: https://example.comneeds to be quoted:url: "https://example.com" - Comments lost on round-trip — YAML comments (
# ...) are not preserved when converting to JSON and back.
Frequently Asked Questions
- What is the main structural difference between JSON and YAML?
- JSON uses explicit delimiters — curly braces {} for objects, square brackets [] for arrays, double quotes for strings, and commas to separate items. YAML uses indentation and whitespace to define structure, making it more human-readable but sensitive to spacing errors. Both represent the same data model of nested key-value pairs and sequences.
- Can all valid JSON be converted to YAML without data loss?
- Yes. JSON is a strict subset of YAML 1.2, meaning all valid JSON is also valid YAML. Every JSON construct has a direct YAML equivalent. The conversion is lossless for all standard JSON types: strings, numbers, booleans, null, objects, and arrays.
- Can all YAML be converted back to JSON?
- Not always. YAML supports features that have no JSON equivalent — multi-line strings, comments, anchors (&) and aliases (*), custom types (!!), and binary data. When converting YAML to JSON, comments are dropped, anchors are resolved inline, and unsupported types may cause errors.
- Why is YAML preferred for configuration files like docker-compose.yml or .github/workflows?
- YAML is preferred for human-authored configuration because it requires fewer characters (no braces or quotes in most cases), supports comments (unlike JSON), allows multi-line strings naturally, and is generally easier to read and edit. JSON is preferred for machine-generated data and APIs due to its strict, unambiguous syntax.
- What are the most common YAML pitfalls when converting from JSON?
- Indentation errors — YAML requires consistent spaces (never tabs). Unquoted special values — "true", "false", "null", "yes", "no", and numbers can be misinterpreted without quotes in YAML. Colon in values — a colon followed by a space starts a key-value pair, so strings containing ": " must be quoted.