JSON to YAML Converter

Paste JSON on the left, get YAML 1.2 on the right with consistent indentation. Runs entirely in your browser — no upload.

  1. Paste JSON into the left textarea.
  2. Click "Convert to YAML". The YAML output appears on the right.
  3. Copy the result, or click Download to save as data.yaml.
  4. If the JSON is invalid, the error message points at the offending position.
What does it do?

Converts JSON to equivalent YAML 1.2. Objects become mappings, arrays become sequences, numbers/booleans/null/strings preserve their type. Output uses 2-space indentation and a 100-column line width by default. Round-tripping JSON → YAML → JSON yields semantically identical data, though comments and ordering nuances are JSON-side limitations to be aware of.

Example

JSON input:

{"name":"Ada","tags":["math","logic"],"active":true}

YAML output:

name: Ada
tags:
  - math
  - logic
active: true

Common JSON errors and how to fix them

JSON has to be valid before this tool can convert it to YAML. The parser points at the line and column of any failure — these are the patterns that account for almost every "invalid JSON" error.

  • Trailing comma. {"a": 1, "b": 2,} is invalid. JSON does not allow a comma after the last element of an object or array.
  • Single quotes. {'a': 1} is invalid. JSON strings and keys must use double quotes.
  • Unquoted keys. {a: 1} is invalid — JavaScript object literals allow this, but JSON does not. Wrap the key in double quotes.
  • Comments. // or /* */ comments are not allowed in strict JSON. Strip them before converting, or use the YAML output (which supports # comments) and paste back semi-manually.
  • Smart quotes. Copy-paste from a word processor sometimes replaces " with curly quotes — JSON rejects those. Retype or paste through a plain-text editor.
  • NaN / Infinity. JSON has no representation for NaN, Infinity, or -Infinity. If your data contains them, choose: serialize as null (loses information) or as the string "NaN" (preserves intent but changes the type).
Frequently asked questions

Why does my YAML output not have comments?

JSON has no comment syntax, so there are no comments to carry over. If you want commented YAML, edit the output by hand after conversion. Some teams encode comments as a `_comment` field in JSON, but those become regular keys in YAML — not actual comments.

Will my key ordering be preserved?

Yes. JSON object key order is preserved as YAML mapping order — same as JSON.parse + JSON.stringify in modern browsers, which retain insertion order. If you need alphabetical sorting, sort the JSON first.

How are deeply nested structures formatted?

YAML output uses 2-space indentation per level, with sequences in block style (one item per line, prefixed with `-`). Empty objects and arrays are rendered as `{}` and `[]` respectively — flow style, since block style would be ambiguous for empty.

Does this support binary data?

JSON has no native binary type, so binary is typically already encoded as a base64 string in the input. The output YAML preserves that string. If you actually need YAML binary format (`!!binary`), the conversion does not produce it — keep the base64 string approach instead.

Is this safe for sensitive JSON like API keys?

Yes. Everything runs in your browser. Your input is parsed and converted by JavaScript on this page; no server is contacted. Verify in your browser developer tools — no network requests fire when you click Convert.

Can I round-trip JSON → YAML → JSON?

For data, yes — semantics are preserved. For exact byte-equivalent text, no — whitespace and quoting normalize. If you need a stable canonical form, run JSON.stringify with sorted keys before paste.