JSON to YAML

Converter

Convert JSON data to YAML format with custom indentation and nested object support. Turn verbose JSON configs into clean readable YAML in a couple of seconds.

Converted
JSON
5 lines
YAML
6 lines

About JSON to YAML

JSON and YAML express the same kinds of data, namely mappings, sequences and scalars, but they serve different audiences. JSON targets programmatic parsing with strict punctuation and no comments; YAML targets human authoring with indentation instead of braces, comments allowed, and multi-line strings supported. Kubernetes manifests, CI pipelines, Ansible playbooks and Docker Compose files are YAML, while API responses and front-end configuration are almost always JSON. Turning an API response into YAML you can paste straight into a config file is therefore an everyday step when troubleshooting or standing up an environment. Conversion parses the JSON into an in-memory tree and re-serializes it according to YAML rules: objects become key-value pairs, arrays become dash-prefixed lists, strings gain quotes where needed, and multi-line strings switch to block scalars. Everything happens in the browser with no server involved, so it works offline and never ships your configuration anywhere. A few practical points. Fix the indent width at two spaces, since YAML forbids tab indentation and a stray tab makes parsing fail immediately; many editors silently convert spaces while pasting, so check. Quote any string containing a colon, a hash, leading whitespace, or a leading digit, or it will be read as a key or a comment, a mistake that shows up constantly with non-English content. On key order, JSON objects are unordered and conversion usually preserves insertion order, but do not treat that as a contract; sort explicitly when order must be stable. The limits deserve their own note. JSON allows only one top-level value per document, so the result has a single root; merging several JSON files into one YAML requires combining them into an array or mapping first. On precision, integers above 2^53 - 1 lose accuracy during the JSON parse itself, so a snowflake ID arrives in YAML with its last digits already zeroed, which is a data-source problem rather than a converter defect. Date and time values in JSON are plain strings while YAML has a dedicated timestamp type, and some parsers silently promote a value like 2026-01-01 into a date object. If a downstream consumer expects a string it will see a type error, so quote the value to force string semantics. Data and privacy: what people convert here is usually deployment configuration containing database hosts, secrets and internal domains, arguably the material least suited to leaving the machine. This tool parses and serializes entirely in the browser and issues no requests. Disconnect the network before converting, or keep the Network panel open and verify that no request carries a payload. When the output feeds a templating tool such as Helm or Kustomize, be aware of one more layer: the template performs another substitution pass at render time, so strings written there can be interpreted again. If a value contains template delimiters such as double braces, escape it or inject it through a variable, otherwise the conversion looks successful while rendering fails on an undefined variable. Recording the three points that still need human review in the change description makes review and rollback much faster. One easily missed detail is key casing: YAML itself is case-sensitive about keys, yet some frameworks lowercase them on read, so a camelCase key becomes all-lowercase at runtime and lookups fail. Writing the key naming rule into the documentation saves an integration round trip.

How It Works Internally

Conversion parses JSON into a tree and serialises it under YAML rules: mappings become indentation, sequences become dash-prefixed items, and multi-line strings become block scalars. The expressive difference is that YAML allows comments and anchors and applies implicit typing (an unquoted yes/no may be read as a boolean), so after converting you should still verify that implicit rules did not rewrite a type.

How the structures map
Input{"name":"oltool","tags":["a","b"]}
Outputname: oltool tags: - a - b

Measured on This Page

Fixed: big integer precisionJSON.parse turns integers past 2^53-1 into doubles, so 9007199254740993 came out as …992. The guard now emits '9007199254740993' as a single-quoted string — every digit intact, at the cost of it being a string rather than a number in YAML
Chinese and nestingChinese keys and values, nested objects and arrays convert correctly with 2-space indent
Round-trip inside YAMLThe output re-parses via yaml.safe_load to an object matching the source (the large number arrives as a string)
Special charactersValues containing colons, hashes or leading spaces are quoted automatically by js-yaml

Direction matters: an outward conversion produces a file that other software will treat as the source of truth, so any value damaged here is damaged permanently rather than merely displayed wrong somewhere. That is why oversized numbers leave this page quoted, labelled as text, with numeric parsing left to whoever needs it. 2 habits make the migration safe: re-read the generated file with a real parser and diff it against the input, and keep credentials out of the intermediate file, since these conversions usually happen on machines shared through chat or tickets.

How this was measured: JSON containing 9007199254740993, Chinese keys and nested arrays was converted, then the YAML re-parsed with Python yaml.safe_load and compared field by field against the source object, before and after the fix. · Measured 2026-10-31

How to Use

  1. Open "JSON to YAML"
  2. Paste the JSON content
  3. YAML updates live as you type
  4. Check indentation, arrays and big integers
  5. Click the copy icon at the top right to take the YAML

Use Cases

  • Write K8s configs — Turn JSON config from an API into indented YAML to paste straight into a Deployment or ConfigMap.
  • Migrate CI pipelines — Convert legacy JSON build config into the YAML required by GitHub Actions or GitLab CI.
  • Make configs readable — Convert verbose single-line JSON to YAML for easier line-by-line review.
  • Reverse validation — Convert hand-written YAML back to JSON to verify indentation and catch hidden type errors.
  • Documentation examples — Show both JSON and YAML forms in docs to suit readers with different habits.
  • Kubernetes manifest — Convert JSON deployment specs to YAML for Kubernetes manifest files that are easier to read and diff.
  • Ansible variable prep — Transform JSON variable definitions into Ansible-compatible YAML syntax for playbook configuration.

FAQ

Must YAML indentation use spaces?

Yes. The YAML spec forbids tab indentation; this tool always emits 2 spaces. If your YAML errors, check for stray tabs first.

Are comments preserved?

JSON has no comments, so JSON→YAML carries none; YAML→JSON drops comments because the target format cannot hold them.

How are multi-line strings handled?

Longer multi-line text is emitted using YAML block scalars (| or >) to keep line breaks readable.

Does key order change after conversion?

No. Original insertion order is preserved — no alphabetical sorting — so you can compare against the source.

Will values like on or yes become booleans?

Possibly. YAML 1.1 treats on/off/yes/no as booleans; keep them quoted in the source if the value is genuinely that literal text, then verify after conversion.

What about converting to TOML?

Use our JSON to TOML or YAML to TOML tools, which also run locally with lossless conversion.

Quotes disappeared — will strings be mis-parsed?

YAML quotes only when required: numeric-looking strings like "1.0" stay quoted while plain text does not. Rare edge cases (short strings starting with special characters) may need manual quotes, so spot-check high-risk fields.

Long text became | or > — what does that mean?

Those are YAML block scalars: | keeps newlines, > folds them into one line. The converter picks based on whether the source contains newlines; if it guessed wrong, change that single indicator — nothing else is affected.