JSON to YAML Converter

Convert JSON to readable YAML. Runs in your browser; nothing is uploaded.

How to convert JSON to YAML

  1. Paste your JSON into Input (JSON), open a .json file, or click Sample. Any JSON syntax errors are underlined immediately with their line and column.
  2. Pick your preferred Indent width (2 spaces or 4 spaces) and click Convert to YAML.
  3. Copy the generated YAML or download it as a .yaml file for Kubernetes, Docker Compose, GitHub Actions, OpenAPI, or Ansible.

How JSON is converted to clean, readable YAML

Objects and arrays are formatted as idiomatic block-style YAML 1.2 that also reads back identically in YAML 1.1 parsers (such as Python's PyYAML).

  • Minimal quoting: keys and strings are left unquoted unless they look like numbers, booleans, ISO dates, or reserved YAML words (such as yes, no, on, off, true, false, or null), or contain YAML syntax characters like : or #.
  • Multi-line strings: strings containing line breaks (\n) are automatically written as readable literal block scalars (|) instead of escaped one-liners.
  • Empty collections: empty arrays and objects are emitted cleanly as [] and {}.
  • Exact numbers: big integers above 253 − 1 keep every digit exactly as written in the JSON input.

Example: JSON configuration to YAML

Input JSON:

{
  "service": "pixlint-web",
  "ports": [80, 443],
  "env": { "NODE_ENV": "production", "FEATURE_FLAG": "yes" },
  "notes": "First line\nSecond line"
}

Converted YAML output:

service: pixlint-web
ports:
  - 80
  - 443
env:
  NODE_ENV: production
  FEATURE_FLAG: "yes"
notes: |-
  First line
  Second line

Frequently asked questions

Why does the converter put quotes around strings like "yes", "no", or "007"?
Unquoted words such as yes, no, on, off, true, false, and null are parsed as booleans or null in YAML 1.1 and YAML 1.2, and strings like 007 or 1.0 are parsed as numbers. The converter quotes only those ambiguous values so that any YAML parser reads them back as strings.
Is JSON already valid YAML?
YAML 1.2 is an official superset of JSON, so raw JSON is technically valid flow-style YAML. Converting JSON to block-style YAML removes braces, brackets, and redundant quotes and turns escaped newlines (\n) into readable multi-line literal blocks (|).
Should I use 2 spaces or 4 spaces for YAML indentation?
Two spaces is the standard convention for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, OpenAPI specifications, and Ansible playbooks. Use 4 spaces if your team or linter prefers wider indentation.