CalcSeed

JSON to YAML Converter

Paste JSON to convert it into an equivalent YAML document.

YAML output
—

What this converter does

Paste a JSON document and the converter re-emits the same data as YAML. The default input — a small object with a name, an age, an array of languages and a boolean — comes out as four top-level keys with two-space indentation, where the languages array becomes two dash-prefixed lines under its key. The output is ready to paste into a Dockerfile, a Kubernetes manifest, a CI pipeline config or any other tool that eats YAML.

How the conversion works

{k:v}→k:v{k:v} \to k: v

The conversion is a parse-then-emit pass. First the input goes through a strict JSON parser, so malformed input — a missing comma, an unquoted key, a trailing comma — returns an error message instead of a half-converted document. Then the parsed tree walks itself recursively: objects emit one key: value line per property, arrays emit one dash-prefixed line per element, and nested structures indent by two spaces per level so parents and children stay visually distinct.

Scalars carry straight across with their types: numbers print bare (36, not "36"), booleans print as true or false, and null prints as null. Strings print quoted, which is a deliberate choice — unconditional quoting removes the whole class of YAML surprises where a value like no, 12:30 or 3.14 gets silently reinterpreted as a boolean, a time or a float.

What changes and what stays

  • Braces, commas and square brackets are replaced by indentation and dashes
  • Strings, numbers, booleans and null keep their meaning
  • Object key order is preserved exactly
  • Strings stay quoted, even when YAML would allow them bare

The default example, line by line

JSON fragmentYAML output
"name": "Ada"name: "Ada"
"age": 36age: 36
"languages": ["JavaScript", "Rust"]languages: then − "JavaScript" and − "Rust" on indented lines
"active": trueactive: true

Two details are worth noticing. The age stays unquoted because it is a number, while the name carries quotes because it is a string. And the inline array collapses into block style: YAML has a flow syntax for arrays too — [JavaScript, Rust] on one line — but the block form with dashes is what most configuration files use, because it diffs cleanly line by line in version control.

Quoting and escaping rules

The two quote decisions

Any double quote or backslash inside a string value is escaped with a backslash in the output, so a name of He said "hi" emits as name: "He said \"hi\". Nothing else in a string is touched — the converter does not attempt the fancier YAML quoting styles such as single-quote doubling or block scalars. That makes the output slightly more verbose than a hand-tuned YAML file, but it is also why the output is byte-for-byte predictable and safe to re-read by any YAML parser.

The second decision is scalar typing. YAML without quotes plays guessing games with values: a bare 12:30 can decode as a sexagesimal number, a bare no as boolean false, and a version string like 1.20 as a float that silently loses its trailing zero. Because this converter quotes every string unconditionally, none of that ambiguity exists — anything inside quotes is a string, anything outside is a number, boolean or null. The output is longer by a handful of characters per line and immune to an entire category of config bugs that have broken real production deployments.

Why use YAML

YAML is easier for humans to read and edit than JSON, which is why it is common in configuration files for tools like Docker, Kubernetes, CI pipelines and static-site generators. Comments are the other practical difference: YAML supports # line comments and JSON deliberately does not, so a converted file can carry explanations next to the values it configures. For machine-to-machine transfer nothing changes — both formats express exactly the same tree, and YAML 1.2 parsers can read most JSON documents directly.

Common mistakes when converting

  • Editing the YAML output afterwards with tabs — YAML forbids tab characters in indentation, and a single tab makes the whole document unparseable; use two spaces like the converter does
  • Assuming an empty object or empty array survives as {} or [] — the block style renders them as a bare key line, and a few edge parsers treat that differently
  • Feeding in JSON5-style input with unquoted keys or trailing commas, which strict JSON parsing rejects
  • Expecting duplicate keys to survive — the JSON parser keeps only the last occurrence of a repeated key, so earlier duplicates vanish
  • Quoting numbers in the source JSON ("age": "36"), which converts them to quoted strings and changes their type in the output

The type question is the one that bites hardest in practice. In JSON, "age": 36 and "age": "36" are different data; after conversion the first prints as age: 36 and the second as age: "36", and downstream YAML consumers will treat them differently too. If a downstream tool insists on a string ID that looks numeric, the quotes must exist on both sides of the conversion.

Round-tripping between the formats

The sibling YAML to JSON converter runs the reverse pass, and a document that goes JSON → YAML → JSON comes back identical except for formatting: key order survives, types survive, and the only visible change is whitespace. What does not survive a round trip is anything YAML-specific — anchors, merge keys, multi-line block scalars and comments have no JSON representation, so they exist only in the YAML half of the journey. Keep the canonical version of commented config in YAML and treat JSON as the interchange format when an API or build step needs it.

Frequently asked questions

Is YAML a superset of JSON?

Mostly. YAML 1.2 can parse JSON documents, though this converter always emits the conventional indentation style rather than inline braces.

Will my object key order change?

No. Keys are emitted in the order they appear in the JSON, so the output stays predictable and diffs stay clean.

Why are strings always quoted in the output?

Unconditional quoting prevents YAML from reinterpreting values: bare no, off, 12:30 or 3.14 can decode as a boolean, a time or a float. Quotes pin every string to its exact content.

What does the default example convert to?

name: "Ada", age: 36, languages as two dash lines with "JavaScript" and "Rust", and active: true — one top-level key per line, two-space indent under languages.

Can YAML represent everything JSON can?

Yes for ordinary data. Nested objects, arrays, strings, numbers, booleans and null all map directly, though YAML adds features like anchors and multi-line strings that JSON lacks.

Why does my JSON fail to parse?

The parser is strict JSON: keys must be quoted, no trailing commas, no comments, no single quotes. A message such as Unexpected token points at the first character the parser could not accept.

How are nested objects indented?

Two spaces per level. Arrays inside objects indent one more level with a dash, so a list of objects renders each dash followed by the first key on the same line.

Do tabs work in the YAML output?

The converter emits spaces only, and you should keep it that way when editing. YAML forbids tab characters in indentation, which is the single most common hand-editing error.

What happens to duplicate keys in my JSON?

The JSON parser keeps the last occurrence of a duplicate key, so an earlier name property is silently dropped. Deduplicate your input if both keys matter.

Method and sources

Calculation basis

Conversions and formats follow the relevant IETF RFCs and IEEE standards, including RFC 4648 for Base64 and RFC 791 for IPv4 addressing.

Last updated: November 18, 2026
Formula & data sources
  • YAML 1.2 specification, indentation-based data serialization.

Cite this page

Reference formats
APA 7CalcSeed. (2026, November 18). JSON to YAML Converter. https://calcseed.com/c/developer/json-to-yaml-converter/
MLA 9"JSON to YAML Converter." CalcSeed, 18 Nov. 2026, calcseed.com/c/developer/json-to-yaml-converter/.
ChicagoCalcSeed. "JSON to YAML Converter." Last modified November 18, 2026. https://calcseed.com/c/developer/json-to-yaml-converter/

Related calculators