T

JSON ↔ YAML

Bidirectional, preserving types and nesting.

JSON
Loading editor…
0 B
YAML
Loading editor…
0 B

JSON to YAML Converter

Converts JSON into YAML and YAML back into JSON, preserving types and nesting in both directions. Numbers stay numbers, booleans stay booleans, and nested structures keep their shape.

YAML is the configuration language of Kubernetes, GitHub Actions, Docker Compose and Ansible, so translating between it and the JSON an API returns is a routine part of the job.

How to use it

  1. Paste JSON on the left to see the YAML equivalent.
  2. Press Swap to convert YAML back into formatted JSON.
  3. Syntax errors on either side are reported with the parser's own message.

Multi-document YAML streams

A YAML file can contain several documents separated by ---, which is common in Kubernetes manifests. Rather than silently returning only the first, this converter returns the whole set as a JSON array so nothing is lost.

A single-document file converts to a single JSON value as you would expect.

JSON is already valid YAML

YAML 1.2 is a strict superset of JSON, so any valid JSON document is also a valid YAML document and will parse unchanged. Converting is therefore about readability rather than compatibility: the point is to move from JSON's braces and quotes to YAML's indentation and bare scalars.

That relationship also explains why converting YAML to JSON and back does not return the file you started with. Indentation, quoting style, comments and anchors are all presentation choices that JSON has no way to record.

Frequently asked questions

Are comments in my YAML preserved?

No, and they cannot be: JSON has no way to express a comment, so converting to JSON necessarily drops them. Keep the YAML as the source of truth if comments matter.

Why did my YAML value become a string, or a number?

YAML infers types, so 1.0 is a number and 'yes' may be read as a boolean depending on the schema. Quote a value in YAML to force it to stay a string.

Does it handle anchors and aliases?

They are resolved during parsing, so the JSON output contains the expanded values rather than references.

Related tools

Everything on this page runs in your browser. TurboParse is a static site with no backend, so nothing you paste is uploaded, logged or stored.

Last updated .