JSON to YAML

Convert JSON into clean YAML.

The JSON to YAML converter turns a JSON document into block-style YAML. Paste JSON into the left pane and the YAML appears on the right as you type, with a choice of 2 or 4 space indentation. Use it to move configuration between tools that prefer one format or the other.

How does JSON map to YAML?

JSON and YAML describe the same kinds of data: objects (mappings), arrays (sequences) and scalars such as strings, numbers, booleans and null. YAML 1.2 was designed so that valid JSON is also valid YAML, which makes this direction of conversion safe in meaning. The difference is presentation. JSON uses braces, brackets, commas and quoted keys, while YAML block style uses indentation and dashes and quotes strings only when they would otherwise be read as another type or would break the syntax. YAML also supports comments, anchors and multiple documents, none of which exist in JSON, so they never appear when converting from JSON. YAML is common in Kubernetes manifests, CI pipelines and application configuration. This tool parses the JSON with the browser's JSON parser and writes it out with the yaml library.

How to use JSON to YAML

  1. Paste JSON Enter a valid JSON document in the JSON pane. Any JSON value is accepted, not only objects.
  2. Choose the indent Select 2 spaces or 4 spaces in the Indent control.
  3. Review the YAML The YAML pane fills in automatically. Check lists and quoted strings.
  4. Copy or download Use the buttons on the YAML pane to copy the text or save it as output.yaml.

Frequently asked questions

Is any information lost when converting JSON to YAML?

No meaning is lost, because every JSON value has a YAML equivalent. Only the presentation changes. Numbers larger than 2^53 can lose precision, though, because the browser parses JSON numbers as floating point: 12345678901234567890 comes out as 12345678901234567000.

Why are some strings quoted and others not?

A plain YAML scalar such as 1.10, true or null would be read as a number, boolean or null. The converter quotes strings that would be misread and leaves ordinary words unquoted.

Can I convert YAML back to JSON?

Yes, use the YAML to JSON tool. Comments are dropped and anchors are expanded on the way back.

Does it keep key order?

Yes, keys are written in the order they appear in the JSON text.

Can the output use tabs?

No. YAML does not allow tabs for indentation, so the output always uses spaces.

Is my data uploaded?

No. The conversion runs in the page and the text you enter is not sent anywhere.