YAML ↔ JSON Converter
Convert YAML to JSON or JSON to YAML. Direction is auto-detected from the input, or you can switch manually.
When to use each format
YAML is great for
- Configuration files — Kubernetes manifests, Docker Compose, GitHub Actions, Ansible playbooks
- Anything humans edit — comments and indentation make YAML easier to read
- Multi-line text — YAML's
|and>block scalars handle multi-line strings cleanly
JSON is great for
- Network APIs — strict syntax means fast, predictable parsers
- Browser interop — every browser ships JSON.parse natively
- Logs and machine-generated data — easier to parse line-by-line (NDJSON)
Common YAML gotchas
- Indentation must be spaces. Tabs are not allowed. Most editors can be configured to insert spaces when you press Tab.
- Norway problem. In YAML 1.1, the bare word
noparses as the booleanfalse. Quote country codes (and any string that looks like a boolean:yes,no,on,off,true,false). YAML 1.2 only treatstrue/falseas booleans, but many tools still use 1.1. - Numeric strings. Version strings like
1.10may parse as the number1.1. Quote them. - Leading zeros.
012may parse as octal 10 in YAML 1.1. Use"012".
Frequently asked questions
Does this preserve YAML comments?
No. The conversion goes through a JavaScript object representation, which doesn't include comments. Round-tripping YAML through JSON and back will strip any # comments.
Why does my JSON output use double quotes when my YAML used single quotes?
JSON only allows double-quoted strings. The values are identical — just the quote style differs.