Two ways of writing the same thing
YAML and JSON describe exactly the same kind of data. JSON is strict and unambiguous, which is why machines send it; YAML has no brackets and allows comments, which is why configuration files use it. Converting between them is a daily job when you work with Docker Compose, Kubernetes, GitHub Actions or OpenAPI.
The traps in YAML
- Indentation is the syntax. Spaces only — a tab character is an error.
- Bare yes, no, on, off are read as booleans in YAML 1.1 tools. Quote them when you mean the words.
- A leading zero, as in a phone number or a time, can be read as an octal number. Quote it.
- Trailing spaces and smart quotes from a word processor break parsing in ways that are hard to see.
How to use the converter
- Pick a direction — YAML to JSON, or JSON to YAML.
- Paste the document. Errors appear with the line number, which is nearly always an indentation problem.
- Choose the indent — two spaces is the convention for YAML, and minified JSON is there for config fields that want one line.
What is lost on the way
- Comments. JSON has none, so
#comments disappear when converting to JSON and cannot come back. - Anchors and aliases are expanded, so repeated blocks are written out in full.
- Dates become strings in JSON, which is usually what you want.
Privacy
The parsing runs in your browser. Configuration files often contain hostnames, keys and internal addresses, so it matters that none of it is uploaded. The YAML library is fetched from a CDN once and then everything happens locally.
Frequently asked questions
How do I convert YAML to JSON?
Paste the YAML above with the direction set to "YAML to JSON". The result appears as you type, and any syntax error is reported with its line number.
Why does my YAML fail to parse?
Nearly always indentation: a tab instead of spaces, or a line indented one space too far. The error message gives the line — check the lines just above it as well.
Do comments survive the conversion?
No. JSON has no comment syntax, so they are dropped going to JSON and cannot be recreated coming back. Keep the original YAML if the comments matter.