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 Line folding
Paste JSON (or load the sample) and hit Convert. Nothing leaves your browser.
Advertisement

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.parseYAML.stringify one way, YAML.parseJSON.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.

Frequently Asked Questions

How do I convert JSON to YAML?

Paste the JSON into the left box and hit Convert: the tool parses it once and re-serializes it as YAML, with 2-space indent by default. Nested objects become indented maps, arrays become dash lists, and strings that could be misread as numbers or booleans get quoted only when necessary. A round-trip check parses the YAML back and confirms nothing changed.

Is YAML a superset of JSON?

Mostly, but not quite, and the exceptions bite. Nearly all JSON is valid YAML — YAML flow style was designed around it. The gaps: JSON allows duplicate keys while YAML parsers reject them ("Map keys must be unique"), JSON allows tab whitespace inside lines while YAML forbids tabs as indentation, and JSON documents can carry a UTF-8 BOM that some YAML tools reject. Converting through a parser rather than by regex handles all of this correctly.

Why do some strings get quotes in the YAML output?

The serializer quotes a string only when a plain scalar would be ambiguous — when it could be read as a number, boolean, null, or type indicator, or when it contains a colon-space or leading special character. So 3.14 stays a number, "true" stays unquoted inside a sentence like 'true story' (which can't be confused with the boolean), but the string "a: b" needs quotes because colon-space is YAML's key separator. That minimal quoting is what keeps YAML readable.

What happens to null, booleans, and multiline strings?

JSON null becomes YAML null, booleans carry over as true/false, numbers keep their value (very large exponents render as 1e+21 style), and an empty string becomes "". A multiline string becomes a block scalar: lines under a |- header (strip the final newline) or | (keep it), which is YAML's readable replacement for JSON's \n escapes.

Can I convert YAML back to JSON?

Yes — switch the direction toggle to YAML to JSON. The same engine parses the YAML (with precise line-and-column errors for tabs, duplicate keys, or bad indentation) and emits formatted JSON. This is also the quickest honest YAML validator: if it parses to the JSON you expected, the YAML is well-formed.

Does my data get uploaded anywhere?

No. The converter loads the yaml library from a CDN and then does all parsing and serialization locally in the page. Config files, credentials, and payloads stay on your machine, and the tool keeps working offline after the library loads.

Advertisement