How to convert YAML to JSON (nested keys, lists, and the gotchas)
Convert YAML to JSON correctly, including nested maps, lists, and multi-line strings, right in your browser, with nothing uploaded.
YAML and JSON describe the same data model, so converting between them is usually clean, until nested structures and YAML's friendlier syntax trip you up. Here's what actually maps, and how to convert safely.
The mental model
YAML is a superset of JSON: every JSON document is valid YAML. Converting YAML to JSON mostly means making the structure explicit.
| YAML | Becomes JSON |
|---|---|
key: value |
"key": "value" |
| Indented block | Nested object { ... } |
- item list |
Array [ ... ] |
true / 42 |
Real boolean / number |
The gotchas
- Indentation is structure. A single wrong space changes nesting. If your output looks flat when you expected nesting, check the indentation.
- Unquoted strings that look like other types.
version: 1.10becomes the number1.1;country: NOcan becomefalse. Quote them ("1.10","NO") if they must stay strings. - Multi-line strings (
|and>) collapse into a single JSON string, with or without newlines. Know which one you want.
Convert it privately
Drop's YAML to JSON tool parses YAML in your browser and shows the JSON as you type. Nested maps and lists are preserved, and nothing is uploaded.
- Paste your YAML (or upload a
.yaml/.ymlfile). - Read the JSON on the right. It updates live.
- Copy it, or download a
.jsonfile.
Need the other direction? Use JSON to YAML.
Try the tool
Do it now — free, in your browser, nothing uploaded.