DataToolsLab
JSON Tools

JSON to YAML

Convert JSON into clean, readable YAML.

Loading tool…

What is JSON → YAML?

The JSON to YAML converter transforms a JSON document into equivalent YAML. Many configuration systems — Kubernetes manifests, GitHub Actions, Docker Compose, Ansible playbooks — use YAML, and a clean converter saves hours of hand-conversion (which is error-prone with indentation-sensitive YAML).

How it works

We parse the input with our hand-rolled JSON tokenizer and serialize with js-yaml, the canonical YAML library. We delegate to a battle-tested YAML engine because hand-rolling YAML serialization is fraught with edge cases — anchors, multi-line strings, the 'Norway problem' (where `NO` is parsed as a boolean false).

  1. Paste JSON. Drop a JSON file or paste JSON text. The converter runs on every keystroke.
  2. Configure indent and style. Pick 2 or 4 spaces and Block vs Flow style. Block is the standard indented form; Flow is compact (suitable for short config snippets).
  3. Copy or download. Download as a .yaml file or copy to clipboard.

Examples

Kubernetes config snippet

Paste a JSON spec block and get YAML ready for kubectl apply — e.g. {"apiVersion":"v1","kind":"ConfigMap", ...} becomes apiVersion: v1, kind: ConfigMap, ...

Flow style for short arrays

Toggle Flow style to produce {a: 1, b: 2} instead of the block-style multi-line output.

Common mistakes

Comments in the JSON

JSON does not allow comments, and the source you paste is parsed strictly. Remove any // or /* */ comments before converting.

Lossy number formatting

JSON allows numbers js-yaml may emit with or without quotes depending on format. The YAML output is structurally equivalent and round-trips through a YAML parser.

Alternatives

YAML to JSON

The inverse direction — convert YAML back into JSON. Coming soon.

JSON Formatter

Stay in JSON with the Formatter; sometimes the simplest path is also the right one.

Frequently asked questions

Does it support YAML 1.2 only?

Yes, js-yaml outputs YAML 1.2, which is what all modern tools (Kubernetes, Docker Compose, GitHub Actions) consume.

Will my YAML round-trip back to JSON?

Structurally yes — every JSON value has an equivalent YAML. Scalar styling may differ (e.g. string vs number formatting), but the parsed objects are equivalent.

Are anchors and aliases preserved?

Out of the box, no — js-yaml is configured with noRefs: true. We can revisit when a YAML ↔ YAML round-trip workflow ships.

Online