toolqik

132 · JSON

JSON to YAML

Convert JSON to clean, correctly quoted YAML for configs, Kubernetes and CI.

Runs in your browser
Indent
Quotes when needed
Options
YAML

  

About this tool

YAML is JSON’s more readable cousin, used for Kubernetes manifests, Docker Compose, GitHub Actions, Ansible, OpenAPI specs and countless config files. Every JSON document can be written as YAML, and this converter does it with the details right: correct indentation, multi-line strings, and quotes wherever YAML would otherwise misread a value.

The quoting problem this avoids

Many strings that are fine in JSON change meaning when written unquoted in YAML:

JSON stringUnquoted YAML reads it asThis converter writes
"NO" (Norway)false in YAML 1.1 parsers'NO'
"yes", "on"true in YAML 1.1 parsers'yes', 'on'
"007"the number 7'007'
"1.10" (a version)the number 1.1'1.10'
"null", "~"null'null', '~'

Real numbers, booleans and null from your JSON stay unquoted, so types survive the round trip.

Options

  • Indent: 2 spaces is the convention for Kubernetes and most tools.
  • Compact (flow) style: writes deeper levels inline, like {min: 2, max: 10} and [GET, POST], for shorter files.
  • Quote every string: some teams prefer it for config files, so nothing is ever ambiguous.
  • Several documents: a top-level array becomes multiple YAML documents separated by ---, the way multiple Kubernetes resources share one file.

Strings with line breaks are written as YAML block scalars (|), which keeps them readable. YAML has no equivalent of JSON’s key-order guarantee problems: order is preserved unless you sort keys.

Convert in code

# Python (PyYAML)
yaml.safe_dump(json.loads(text), sort_keys=False, allow_unicode=True)

// JavaScript (js-yaml)
yaml.dump(JSON.parse(text), { noRefs: true })

# Command line (yq v4)
yq -P '.' data.json

FAQ

How do I convert JSON to YAML?

Paste JSON above. The YAML appears instantly; copy it or download it as a .yaml file.

Why are some strings quoted in the YAML?

Because unquoted they would change meaning: "yes", "no", "on" and "off" can become booleans, "007" a number and "null" a null. Quoting keeps them strings.

Is JSON valid YAML?

Almost always. YAML 1.2 is designed as a superset of JSON, so most YAML parsers can read JSON directly. Converting gives you the cleaner, more readable block style.

How do I put several Kubernetes resources in one YAML file?

Paste a JSON array of resources and turn on “Top-level array = several documents”. Each item becomes a separate YAML document separated by ---.

Are comments preserved?

JSON has no comments, so there are none to carry over. You can add YAML comments (# like this) after converting.

esc
↑↓ navigate↵ open