To convert JSON to YAML, paste the JSON on the left and hit Convert: nested objects become indented maps, arrays become dash lists, and quoting appears only where a plain scalar would be ambiguous. The engine is eemeli/yaml (the modern successor to js-yaml) compiled for the browser, so Kubernetes configs, GitHub Actions workflows, and docker-compose files come out exactly the way those tools expect. A sample conversion: a 397-byte JSON service config converts to a 274-byte YAML file, parses back equal to the original, and long prose lines fold at column 80 unless you turn folding off. Switch the toggle to go YAML → JSON, with line-and-column parse errors when the input is broken.

Converter

Indent
Ad
Line folding
Paste JSON (or load the sample) and hit Convert. Nothing leaves your browser.
Ad

JSON Types in YAML Output — Engine-Verified

JSON valueYAML outputWhy
"hello"helloPlain scalar — nothing ambiguous
"true story"true storyWhole-string match would be a boolean; a phrase never is
"a: b""a: b"colon-space is the key separator — must be quoted
3.14, 42, -73.14, 42, -7Numbers pass through unchanged
1e211e+21YAML's canonical exponent form
true / falsetrue / false1:1 mapping
nullnullExplicit null (also valid: ~)
""""Empty string can't be a plain scalar
[1, 2, 3]- 1 linesBlock sequence, one dash per item
{"a":{"b":"c"}}indented mapNesting becomes indentation
"line1\nline2"|- blockBlock scalar replaces \n escapes
"café ☕"raw UTF-8No \u escapes — YAML is Unicode-native

Every row is the actual output of the yaml 2.9 engine this page runs, not a paraphrase. The minimal-quoting behavior is the same serializer Ansible, Jest, and the AWS CDK use through this library.

How the Converter Works

JSON and YAML differ in surface, not in data model: both express null, booleans, numbers, strings, arrays, and objects. Converting is therefore two steps — parse to a real value, then serialize in the target syntax — and every subtle bug in naive converters comes from skipping the parse and rewriting text with regexes. This tool always round-trips through the data: JSON.parse → YAML.stringify one way, YAML.parse → JSON.stringify the other, on the eemeli/yaml engine loaded from a CDN and executed locally.

The options that matter

Indent changes nesting width (2 spaces is the Kubernetes and GitHub Actions convention; 4 is common in older configs). Line folding wraps long plain scalars at column 80 with a continuation indent — the 80-column habit comes from terminals and code review diffs — and can be turned off when every value must stay on one line, as some strict pipelines require. Both are passed straight to the serializer.

How to use it

A worked example

A service config in JSON: a name, a replica count, a nested metrics block with enabled and interval_sec, a two-port array, a null timeout, and an environments list of two objects. In JSON that's 397 bytes over 25 lines. Converted at 2-space indent it becomes 274 bytes of YAML over 16 lines — the ports collapse into dash items, the environments entries read as clean stanzas, and the null stays explicit. Parsing that YAML back yields a value deep-equal to the original JSON object, which the tool verifies on every run rather than assuming. Folding shows up on prose: a 164-character description string wraps into three folded lines at column 80 by default and stays on one line with folding off.

YAML to JSON: What Happens to Tricky Values

Going from YAML to JSON is where surprises happen, because YAML guesses types from how values look. We ran these through the same yaml 2.9 engine this page uses. The left column is the YAML you paste; the middle is what comes out in JSON:

YAML inputJSON outputWhat to know
country: no"no"String. YAML 1.2 dropped yes/no/on/off booleans
on: push"on" keyString key, which is what GitHub Actions expects
version: 1.101.1A number, so the trailing zero is gone. Quote it
zip: 012341234Leading zero lost. Quote codes and IDs
mode: 0o755493Octal read as a number; plain 0755 is decimal 755
date: 2026-10-22"2026-10-22"Stays a string; no date type in the default schema
time: 12:30"12:30"String (YAML 1.1 parsers read 750)
big: 1234567890123456789012345678901234567000Beyond JavaScript number precision
empty: or tilde: ~nullBoth are null
x: .infnullJSON has no Infinity, so it serializes as null
&anchor / *aliasCopied valuesAliases are expanded into full copies
<<: *base merge keyA literal "<<" keyMerge keys are YAML 1.1; not merged by default
Duplicate keyError: DUPLICATE_KEYMap keys must be unique
Tab used to indentError: TAB_AS_INDENTYAML indentation is spaces only
Two documents split by ---Error: MULTIPLE_DOCSConvert one document at a time
# commentsDroppedJSON has nowhere to keep them

The three to watch are version numbers, leading zeros and anything that looks like a number but isn't one: ZIP codes, phone numbers, account IDs, git SHAs made of digits. YAML reads them as numbers and the formatting is lost before JSON ever sees it. Put them in quotes in the YAML and they come through as strings.

Comments are the other casualty. JSON has no comment syntax, so a round trip from YAML to JSON and back loses every one of them. Keep the YAML file as your source of truth and generate JSON from it, not the other way round.

The Norway Problem: When the YAML Goes to an Older Parser

This converter writes YAML 1.2, where no, yes, on and off are ordinary strings, so it leaves them unquoted. Many tools still read YAML 1.1, where those words are booleans. We converted JSON with those values and loaded the output in PyYAML 6.0.3, the parser Python projects and Ansible use:

JSON inYAML out (this converter)What PyYAML reads
{"country": "no"}country: noFalse
{"on": "yes"}on: yes{True: True}
{"o": "off"}o: offFalse
{"t": "12:30"}t: 12:30750 (base-60 number)
{"d": "2026-10-22"}d: 2026-10-22A date object, not a string
{"v": "1.10"}v: "1.10""1.10" (correct, already quoted)

The name comes from country lists, where Norway's code NO turned into false. If the file will be read by Python, Ansible or another YAML 1.1 tool, put quotes around any value that's yes, no, on, off, y, n, a time like 12:30 or a date you need as text. The YAML validator shows how a file parses, and the JSON formatter is handy for checking the JSON side before you convert.

Frequently Asked Questions

How do I convert JSON to YAML online?

Paste your JSON into the converter and it parses and re-serializes it as YAML entirely in your browser — no upload to any server. The conversion preserves nested objects, arrays, and scalar types exactly. Invalid JSON is flagged with a parse error so you can fix it before converting.

Is YAML always more compact than JSON?

Usually yes, because YAML drops quotes, braces, and commas in favor of indentation, but not always. Very short values, deeply nested single-item arrays, and strings containing special characters can make YAML as long or longer than JSON. YAML also permits multiple equivalent renderings (flow vs block style) of the same data.

What JSON features have no clean YAML equivalent?

Everything in JSON maps to YAML cleanly except duplicate keys and certain edge-case numbers like leading-plus exponents, which YAML parsers may reject or normalize differently. YAML 1.1 vs 1.2 spec differences can also change how things like booleans (on/off/yes/no) are typed on round-trip. For config files this rarely matters, but strict round-tripping is not guaranteed.

Why did my version number 1.10 turn into 1.1?

Because unquoted 1.10 in YAML is a number, and numbers don't keep trailing zeros. The same happens to leading zeros, so 01234 becomes 1234. Quote the value in your YAML, version: "1.10", and it converts as the string "1.10".

Why does no or yes become false or true in my YAML?

YAML 1.1 parsers such as PyYAML treat yes, no, on and off as booleans. This converter writes YAML 1.2, where they're strings, so it leaves them unquoted. If an older parser will read the file, put those values in quotes.