JSON to YAML Converter

Top-level keys—
YAML lines—
Status—

How JSON to YAML Converter is calculated: JSON.parse → YAML emitter (2-space indent, quoted when needed) — all in your browser

What is JSON to YAML conversion?

JSON and YAML are two ways of writing the same structured data. JSON is the format APIs speak: braces, brackets, quotes, and commas. YAML is the format configuration files speak: indentation, colons, and dashes, with no braces at all. The same settings — a name, an age, a server address — can be written in either, and converting between them is a daily chore for developers.

This converter takes JSON and gives back YAML. Paste JSON into the box and the YAML appears below instantly, indented with two spaces per level, with strings quoted only when they need it. Nested objects become nested indentation, arrays become dash lists, and the structure survives the trip intact.

Everything happens in your browser. The JSON never leaves your device, so you can convert API keys, private settings, and internal configuration without sending them to a website. That is the honest way to run a format converter — the data stays yours.

The two formats also have different audiences. JSON was designed for programs to read: strict, explicit, and the same in every language. YAML was designed for people to read: short, clean, and free of punctuation noise. Converting is therefore not just a format change — it is a translation from machine-friendly to human-friendly, and the converter keeps the meaning identical while changing the presentation completely.

How the JSON to YAML conversion works

The converter first parses the JSON — checking that every brace, bracket, and quote is in place. If the JSON is invalid, it says so plainly and shows the parser's error message, instead of guessing. A missing comma or an unclosed brace is the usual cause, and the error message points at the position where the parser gave up.

Then it walks the parsed structure and writes YAML. An object becomes a set of key: value lines, indented two spaces per level. An array becomes a list of dash items. A string is written bare unless it contains a character YAML would misread — a colon, a hash, a leading space, or a word like true that YAML would read as a boolean — in which case it is wrapped in single quotes.

Numbers, booleans, and null pass through unchanged: 36 stays 36, true stays true, null stays null. Empty objects become {} and empty arrays become []. The result is standard YAML that any parser — Python's PyYAML, Ruby, Go, or a Kubernetes config loader — will read back into the same data.

Quoting rules: the detail people get wrong

YAML quoting is where most converters slip up, and it is the detail this one is careful about. A string like hello: world contains a colon, and unquoted YAML would read hello as a key and world as its value — a completely different structure. So the converter quotes it: 'hello: world'. The same applies to strings starting with #, [, {, or a space.

Words that look like other types are quoted too. The string true must be written as 'true', or YAML will read it as the boolean true. The string 123 must be '123', or it becomes the number 123. The words yes, no, on, and off are quoted for the same reason — older YAML versions treated them as booleans, and quoting removes all doubt.

Strings that are safe stay bare: Ada, London, localhost. That keeps the output readable, which is the whole point of YAML. A converter that quotes everything produces valid YAML that nobody wants to read; a converter that quotes nothing produces YAML that silently changes your data. The rule is simple: quote only when the meaning would change otherwise.

A worked example: a small object, a nested object, and a list

Take the default input: {"name": "Ada", "age": 36, "city": "London"}. The YAML is three lines: name: Ada, age: 36, city: London. Three top-level keys, three lines, and the status reads Valid JSON. That is the simplest possible conversion, and it shows the shape of the output.

Try a nested object: {"server": {"host": "localhost", "port": 8080}, "debug": true}. The YAML is server: on one line, then host: localhost and port: 8080 indented two spaces beneath it, then debug: true back at the top level. Two top-level keys, four lines. The nesting is shown by indentation alone — no braces, no brackets.

Try a list of objects: [{"name": "Ada", "age": 36}, {"name": "Grace", "age": 40}]. The YAML is - name: Ada, then age: 36 indented under the dash, then - name: Grace and age: 40. Four lines, zero top-level keys — because the top level is a list, not an object. Each dash starts a new item, and the fields line up beneath it.

Who uses a JSON to YAML converter

Developers writing configuration files use it the most. Kubernetes manifests, GitHub Actions workflows, Docker Compose files, and Ansible playbooks are all YAML, while the APIs and tools that generate their settings usually speak JSON. The converter bridges the two without retyping — paste the JSON the API gave you, take the YAML your config file needs.

DevOps engineers use it when moving settings between systems: an AWS response in JSON becomes a config file in YAML, or a JSON schema becomes a YAML example in documentation. Technical writers use it to show the same example in both formats, so readers can copy whichever their tool expects, and the JSON to CSV converter turns the same data into a spreadsheet when a table is what is needed.

Students learning either format use it to see the correspondence. Write a structure in JSON, convert it, and the YAML shows what each brace and bracket meant. It is a faster teacher than a reference page, because the example is your own data, not someone else's.

Support teams use it when a customer pastes a JSON error or a JSON settings dump into a ticket. Converting it to YAML makes the structure readable at a glance, so the faulty setting stands out instead of hiding inside braces. The same trick helps in code reviews: a YAML version of a JSON config is easier to scan for a wrong value than the JSON original, especially when the file is long.

JSON vs YAML: which format should you use

JSON is the better format for machines: it is strict, unambiguous, and every programming language parses it the same way. APIs, data files, and anything exchanged between programs should be JSON. YAML is the better format for humans: it is shorter, easier to read, and easier to edit by hand, which is why configuration files use it.

YAML's readability is also its risk. Indentation is meaningful, so a single extra space can change the structure — or break the file entirely. Tabs are forbidden in YAML, and a tab-indented file will fail in every parser. JSON's braces make the structure explicit, which is why it is safer for generated data.

The YAML to JSON converter is the companion page — it goes the other way, from YAML back to JSON, with its own parser for the YAML subset it handles. Use this page to go from JSON to YAML, and that page to come back. A round trip should give you back the data you started with.

Common mistakes in JSON to YAML conversion

The most common mistake is feeding the converter invalid JSON and blaming the output. A trailing comma after the last item, a single-quoted string, or an unquoted key are all invalid in JSON, even though they look fine. The converter reports Invalid JSON with the parser's message — fix the JSON first, then convert. The JSON formatter will validate and tidy JSON before you convert it.

Second: trusting YAML that was converted from JSON with duplicate keys. JSON technically allows duplicate keys, keeping the last one; YAML parsers may keep the first, the last, or complain. If your JSON has two keys with the same name, fix it before converting. Third: losing number precision — very large numbers and long decimals can round differently in YAML, so check values with more than 15 significant digits after conversion.

Fourth: pasting YAML into the JSON box by accident. The converter only reads JSON, so YAML input fails with Invalid JSON. If your input uses indentation instead of braces, you have the wrong direction — use the YAML to JSON converter instead.

How to use this JSON to YAML converter

Paste your JSON into the box at the top. The YAML appears instantly in the output box below, with the top-level key count, the line count, and a Valid JSON status above it. If the JSON is invalid, the status says so and the output shows the parser's error message — fix the JSON and the YAML follows.

Copy the YAML from the output box and paste it into your configuration file, workflow, or manifest. Check the indentation in your editor — two spaces per level, no tabs — and validate the file with your tool of choice before deploying it. A quick test with a small file beats debugging a large one. Validate the converted YAML in your deployment pipeline before it reaches production, and keep a copy of the original JSON alongside it until the new config is proven.

Everything runs in your browser with no sign-up and nothing uploaded. For the reverse direction, the YAML to JSON converter is the companion page, and the JSON formatter validates and tidies JSON before you convert it. Test before deploying.

Frequently Asked Questions

Yes, for ordinary data — objects, arrays, strings, numbers, booleans, and null all survive the round trip. The exceptions are duplicate keys, which JSON and YAML handle differently, and numbers with more than about 15 significant digits, which can round. Check those two cases after converting.

A string is quoted when YAML would otherwise misread it: if it contains a colon or hash, starts with a special character, or looks like a boolean, a null, or a number. The string 'hello: world' is quoted because unquoted YAML would read it as a key and a value. Safe strings like Ada stay bare, which keeps the output readable.

Yes — the YAML to JSON converter on this site goes the other way. Paste YAML and it returns JSON. A round trip (JSON to YAML and back) should give you the same data you started with, apart from formatting and key order.

The usual causes are a trailing comma after the last item, single-quoted strings, or unquoted keys — all invalid in JSON. The converter shows the parser's error message, which points at the problem. Paste the JSON into the JSON formatter first to validate and tidy it, then convert.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.