What is a JSON to YAML converter?
A JSON to YAML converter changes the notation of a document without changing the data inside it. The same object that is written as {"name": "John", "age": 30} in JSON becomes name: John and age: 30 in YAML. Every key, every value, every type and the order of the entries survive the trip; what changes is the syntax around them.
The two formats describe the same shapes. A JSON object maps to a YAML mapping, a JSON array maps to a YAML sequence, and each level of nesting is one level of indentation. JSON spells that nesting with braces, brackets, commas and quoted keys; YAML replaces all of that punctuation with indentation and leaves the structure to be read off the page.
That is why the conversion is so common in day-to-day work. Kubernetes manifests, Docker Compose files, CI/CD workflows, GitHub Actions, Helm charts and a long list of DevOps and application configuration files are written in YAML, while APIs, log lines, database exports and config blobs usually arrive as JSON. Converting between them is how you get from one to the other without retyping anything by hand.
How to convert JSON to YAML
The workflow is three steps: paste, convert, copy.
- Paste valid JSON into the JSON Input panel on the left. Use Load Example if you want to try one of the ready-made documents first, or Upload .json to read a file from your machine.
- Click Convert to YAML. The document is parsed and written out as block-style YAML with two spaces of indentation per level. Conversion also runs automatically while you type, so the button is a shortcut rather than a requirement.
- Read the generated YAML in the YAML Output panel, then use Copy YAML or Download to take it. Download writes a .yaml file that is ready to drop into a repository.
- If your JSON does not parse, the panel reports the line and column of the first syntax error and points at the offending line. Nothing is converted, and your input stays exactly as you typed it so you can fix it in place.
The conversion happens entirely in your browser. There is no upload step, no account and no usage limit, so it is equally usable for a three-line config snippet and for a multi-megabyte API response.
JSON to YAML example
The same document appears below as JSON and as the YAML this converter produces. Nothing was added and nothing was removed: the nested object and the array are still there, they are just written with indentation instead of braces and commas.
The objects become mappings and the array becomes a sequence with one dash-prefixed item per line. Booleans and nulls are written bare because that is how YAML spells them, while a value that would change type if it were left unquoted - such as the string "1.0" - is written in quotes so it is still read back as a string.
{
"name": "John",
"age": 30,
"active": true,
"skills": ["JavaScript", "Python"],
"address": {
"city": "Lahore",
"country": "Pakistan"
}
}name: John
age: 30
active: true
skills:
- JavaScript
- Python
address:
city: Lahore
country: PakistanWhat the converter preserves
Keys keep their order and their exact spelling, including keys that need quoting. Values keep their type: a JSON number becomes a YAML number, true and false stay booleans, null stays null, and everything else stays a string.
Nesting is preserved exactly, including the awkward cases: an array of objects, an object nested inside an array, an array of arrays, and empty objects and arrays, which are written as {} and [] so the document never contains a key with nothing under it.
A JSON string is only written as a plain YAML scalar when that is unambiguous. If the value would be read back as a number, a boolean, null or a date - "30", "true", "3.14", "2024-01-15" - or if it contains a colon, a hash, a quote, a newline or a leading indicator character, it is quoted and escaped instead. That is what keeps the type of your data stable on the way out.
One limit is worth knowing about, and the converter tells you when it hits it: an integer longer than 15 digits is too big for a JavaScript number to hold exactly, so it is rounded. If that happens, a yellow note appears under the editor naming the values that were affected. Keep such an identifier as a JSON string if the exact value matters.
JSON vs YAML: when to use which
Neither format is universally better - they are built for different jobs, and choosing the right one is usually about who or what reads the file next.
| Aspect | JSON | YAML |
|---|---|---|
| Typical use | APIs, data interchange, database and log payloads | Configuration files, Kubernetes manifests, CI/CD workflows |
| Structure is written with | Braces, brackets and commas | Indentation |
| Key syntax | Always double-quoted | Usually plain, quoted only when required |
| Syntax strictness | Very strict - one shape, no extras | Permissive, with several ways to write the same thing |
| Comments | Not allowed | Allowed with # |
| Reading and editing by hand | Works, but noisier on long documents | Designed for it |
| Typical size for the same data | Larger - every key and brace is written out | Smaller - the punctuation is gone |
A practical rule: if a program on the other end parses the data, or if it travels over a network or gets stored in a database column, use JSON. If a person has to read, review and edit the file, use YAML - most tools that read YAML also read JSON, because YAML is a superset of it, but not the other way round.
Related JSON tools
Converting JSON to YAML is only one of the jobs a JSON workflow involves. These are the other Calzyra tools you are most likely to reach for next.
- Need to make minified or compact JSON readable before you convert it?JSON Formatter
- Need to check whether a document is valid JSON and find the exact syntax error?JSON Validator
- Need to explore a deeply nested document as collapsible nodes?JSON Tree Viewer
- Need to shrink JSON back to a single line for a URL or a payload?JSON Minifier
- Need the same prettifying job under its other name?JSON Beautifier
- Need the output as rows for a spreadsheet instead of YAML?JSON to CSV Converter
- Need TypeScript types generated from your JSON structure?JSON to TypeScript Interface
- Need an XML document instead of YAML?JSON to XML Converter
Frequently Asked Questions
What is a JSON to YAML converter?
A JSON to YAML converter takes a document written in JSON syntax and rewrites the same data in YAML syntax. Keys, values, value types and their order stay exactly the same - only the notation changes. JSON uses braces, brackets, commas and quoted keys; YAML drops the punctuation and expresses the same structure with indentation, which is why the result is usually shorter and easier for a person to read.
How do I convert JSON to YAML?
Paste your JSON into the JSON Input panel, press Convert to YAML, then read the result in the YAML Output panel and copy it. Conversion also runs automatically as you type. Everything happens inside your browser, so there is nothing to install and your data is never uploaded.
Is this JSON to YAML converter free?
Yes. It is free to use with no sign-up, no usage limit and no watermark. Because the conversion runs locally in your browser, there is also no upload size limit, which makes it usable for large API responses and config exports.
Can I convert nested JSON to YAML?
Yes, and nesting is the normal case. A JSON object becomes a YAML mapping and a JSON array becomes a YAML sequence, each indented two spaces further than its parent. Objects inside arrays are written with a dash followed by their keys, so an arbitrarily deep document converts in one pass. The status line reports the number of levels it found.
Can I convert JSON arrays to YAML?
Yes. An array becomes a YAML sequence written one item per line with a leading dash. Arrays of scalars look like a list of values, and arrays of objects become a list of mappings. A top-level array converts to a top-level YAML sequence, and an empty array is written as [] so the document stays valid.
Does the converter validate JSON?
Yes. The input is parsed with a strict JSON parser before anything is written, and if it does not parse the converter reports the first syntax error with its line, column and the offending line of text. No YAML is produced in that case, and your input is left untouched so you can fix it in place.
Why are some of my values wrapped in quotes in the YAML?
Because the value is a string that would otherwise be read back as something else. A JSON string such as "30", "true" or "3.14" looks exactly like a number, a boolean or a decimal to a YAML reader, so it has to be quoted or the type of your data would silently change. The same applies to values containing a colon, a hash, a quote or a newline.
What is the difference between JSON and YAML?
JSON is a strict data interchange format: it is parsed by machines, it has no comments, and every key is quoted. YAML is a superset of JSON designed to be written and read by people: structure comes from indentation, keys are usually unquoted, and it supports comments, anchors and multiple documents. Use JSON when something else parses the data, and YAML when a person maintains the file.
Does converting JSON to YAML lose any data?
No. Keys, values, booleans, nulls, numbers and the order of every entry are preserved, and the nesting is identical. The only thing that is lost is the original text formatting, because the document is parsed and written back out - so 1.0 may be written as 1. Numbers with more precision than a JavaScript double can hold are the one genuine exception, and that limit comes from the browser rather than from the conversion.