Guide
Converting YAML to JSON, and the type traps to watch for
YAML and JSON describe the same kinds of data: objects, lists, strings, numbers, true/false and null. YAML is easier to write by hand, which is why Docker Compose, Kubernetes, GitHub Actions, Ansible and many apps use it for configuration. JSON is what most APIs and programs expect. This converter goes both ways in your browser and shows exactly how YAML interprets your values.
Converting
- Choose the direction: YAML → JSON or JSON → YAML.
- Paste your data; the result appears as you type.
- Choose 2 or 4 spaces of indentation.
- Copy the result or download it as data.json or data.yaml.
- Use the swap button to feed the result back in and convert the other way.
Example
service: invoices
port: 8080
debug: false
owners:
- ada
- grace
becomes
{
"service": "invoices",
"port": 8080,
"debug": false,
"owners": ["ada", "grace"]
}
(The converter puts each list item on its own line; it’s shortened here.)
YAML type traps
YAML guesses types from how values look. That’s convenient until it guesses wrong. This converter follows YAML 1.2, the current version; some tools (PyYAML, older Ruby and Go libraries) still follow YAML 1.1 and guess even more:
| You write | You might expect | This converter gives | Older YAML 1.1 tools | Fix |
|---|---|---|---|---|
version: 1.10 |
“1.10” | the number 1.1 | the number 1.1 | version: "1.10" |
zip: 01234 |
“01234” | the number 1234 | a number, possibly octal (668) | zip: "01234" |
country: NO (Norway) |
“NO” | “NO” | false | country: "NO" |
time: 12:30 |
“12:30” | “12:30” | the number 750 (12 × 60 + 30) | time: "12:30" |
Converting to JSON is a quick way to see what a YAML file really means. If a value in the JSON isn’t what you meant, quote it in the YAML. Quoting is also the safest choice when the same file is read by several tools.
Other differences
- Comments (
# like this) exist in YAML but not in JSON, so they’re dropped. - Several documents in one file, separated by
---, become a JSON array of documents. - Anchors and aliases (
&default,*default) are expanded, so repeated sections appear in full in the JSON. - Indentation is meaningful in YAML. Use spaces, never tabs.
- Multi-line strings written with
|(keep line breaks) or>(fold into one line) become ordinary JSON strings with\nwhere line breaks are kept.
JSON to YAML
Converting JSON to YAML is handy for writing configuration from an API response or turning a JSON example into a readable config file. Keys keep their order, long lines are wrapped at about 120 characters, and strings are quoted only where YAML needs it.
When parsing fails
Common causes are tabs in the indentation, inconsistent indentation inside a list, and an unquoted value with a colon and a space, such as title: Part 1: Intro. Quote the value: title: "Part 1: Intro". The error message from the parser points to the problem.
Privacy
Files are converted in your browser, so configuration with hostnames or internal settings isn’t uploaded. Still, avoid pasting real passwords and keys into any tool you don’t need to.
Who converts YAML and JSON
- DevOps engineers work with Kubernetes, Docker Compose and CI configuration files.
- Developers convert configuration for tools that expect JSON.
- API designers switch OpenAPI specifications between YAML and JSON.
- Students learn both formats side by side.
A complete example: checking a CI configuration
A CI pipeline fails with a type error on a version number:
- Paste the YAML and look at the JSON output.
- A value like
python-version: 3.10appears as the number 3.1. - Quote it in the YAML,
python-version: "3.10", and convert again to confirm.
Tips
- Quote values that look like numbers but aren’t, such as versions and ZIP codes.
- Keep the YAML as the source of truth if it has comments.
Related tools
- JSON Formatter to check and tidy the JSON, with line-and-column errors.
- CSV to JSON when your data is a table rather than a config file.
- Diff Checker to compare two configuration files.
Checked against the current version of the YAML ⇄ JSON on .

