JSON to YAML Converter
Convert JSON data to YAML format
About This Tool
Paste valid JSON in the left pane and the YAML equivalent appears on the right. The converter preserves nesting, types, and key order, then emits two-space-indented YAML with quoted strings only where YAML's ambiguity rules require them.
JSON-to-YAML is mostly a syntax swap, but a few edge cases need watching. JSON's null becomes YAML's ~ or null. Numbers that JSON allows but YAML treats specially (Infinity, NaN, hex literals) are quoted as strings to preserve them. Multi-line strings collapse onto one line by default — switch to block scalar mode if your YAML target prefers that.
The reverse direction (YAML to JSON) is lossier because YAML allows constructs JSON doesn't, like anchors, aliases, and tagged types.
The transformation walks the JSON tree depth-first. Objects become YAML mappings; arrays become YAML sequences (-prefixed lines). Primitives map directly: strings stay strings (with quoting if needed), numbers stay numbers, booleans become true/false, null becomes null or ~. Indentation is two spaces per nesting level by convention — three or four work too if your project prefers, but two is the default in most YAML libraries (PyYAML, js-yaml, the Go stdlib).
Worked example: JSON input {"name":"web","replicas":3,"env":{"NODE_ENV":"prod"}}. YAML output: name: web replicas: 3 env: NODE_ENV: prod
The order is preserved, types are preserved, and the nested object becomes a nested mapping with two-space indent. Now paste a tricker input: {"version":"3.10","alive":"yes"}. Naive output makes version a string and alive a boolean — wrong on alive. The converter quotes strings that would auto-type into something else: 'yes', 'no', 'true', 'false', 'on', 'off', 'null', dates like '2024-01-01', and anything fully numeric where you wanted text.
Failure modes to watch for: tabs in indentation (YAML rejects them — only spaces). Trailing whitespace on lines (mostly harmless but some strict parsers complain). Strings containing colons that aren't quoted (the parser reads them as key: value pairs). When a downstream YAML parser rejects your output, paste the result into a YAML linter or a fresh parser and read the error — most YAML parse errors point at the exact line and column of the conflict.
Where YAML's flexibility hurts you: it auto-types unquoted strings aggressively. Country code 'NO' becomes boolean false in YAML 1.1. Postal code '01234' loses its leading zero unless quoted. Phone number '+1234567' gets parsed as integer addition. The converter quotes any string that would auto-type, but if you're hand-editing YAML elsewhere, watch for these — they're a common source of silent data corruption.
The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.