LazyTools

🔒 Every tool runs in your browser, the files and values you enter are never uploaded to any server. How it works

📝 JSON to YAML Converter

Paste JSON, get equivalent YAML, the format Kubernetes, GitHub Actions and docker-compose expect.

converted with js-yaml

Rate this tool:
Anonymous, no account, no identifier

How the json to yaml converter works

The JSON is parsed (with line/column errors if invalid), then serialized by js-yaml, the de-facto standard YAML library, producing block-style YAML with sensible quoting. Every JSON document is valid YAML semantically, so the conversion is lossless. Structurally, each nested object becomes an indentation level, arrays become a list of "- " items, and scalars carry over unchanged: {"replicas": 3} becomes replicas: 3 and ["prod","staging"] becomes a two-line dash list. Because YAML is a strict superset of JSON, the round trip back through the YAML-to-JSON tool reproduces the same values.

The everyday use is configuration: an API response or JSON config that needs to become a Kubernetes manifest, GitHub Actions step or docker-compose fragment. Since YAML relies on indentation, converted output is also a quick way to get canonically indented config from messy hand-written JSON.

Frequently asked questions

Is JSON to YAML always lossless?

Yes, YAML is a superset of JSON, so every JSON value has an exact YAML representation. The reverse direction can be lossy only for YAML-exclusive features (anchors, comments).

Why are some strings quoted in the output and others not?

js-yaml quotes only where YAML requires it, strings that would otherwise parse as numbers, booleans (yes/no/on/off) or contain special characters. Unquoted output is safe.

Does it handle deep nesting?

Yes, nesting converts to indentation levels without depth limits. Very wide values wrap at 100 characters for readability.

Can I convert a whole file?

Use the open-file button, convert, then download, no size caps, all local.

How do arrays of objects convert?

Each object in the array becomes a dash-prefixed block. For example [{"name":"web","port":80}] becomes a list whose single item reads "- name: web" with "port: 80" indented on the next line, the standard YAML idiom for a Kubernetes containers or steps list.

Will the indentation be two spaces?

Yes, js-yaml emits two-space indentation per level and never uses tabs, which YAML forbids for indentation. That makes the output safe to paste straight into a manifest or CI file without reformatting.

Is my config data private?

Yes, configs often contain hostnames and secrets, which is exactly why this runs entirely in your browser.

Related file converters

From the blog