Guides Knowledge Base

YAML to JSON Converter

Convert YAML to JSON online. Paste a Kubernetes manifest, Docker Compose file or CI pipeline and get valid JSON back. Free, runs entirely in your browser.

Switch the direction selector to YAML → JSON, paste your YAML, and the same data comes back as JSON. Indentation-based nesting becomes braces and brackets, and YAML scalars are mapped to JSON strings, numbers, booleans, and null.

YAML Is a Superset, So One Direction Can Fail

Every JSON document is valid YAML, which makes JSON → YAML always safe. The reverse is not guaranteed: YAML has features JSON has no representation for, and a document using them cannot round-trip. Watch for anchors and aliases (&name / *name), which are expanded inline; non-string mapping keys, which JSON requires to be strings; multiple documents separated by ---; and explicit tags such as !!binary.

The Norway Problem

YAML 1.1 treats yes, no, on, off, y, and n as booleans, which is why a country list containing NO for Norway parses as false. Quote such values in the YAML source — "NO" — if you want a string. Converting to JSON is a quick way to see which reading your YAML actually gets.

Multi-line Scalars Become Escaped Strings

description: |
  line one
  line two

becomes {"description": "line one\nline two"}. The literal block indicator | keeps the newlines; the folded indicator > joins the lines with spaces instead.

On the Command Line

# yq
yq -o=json '.' manifest.yaml

# Python
python3 -c "import sys,yaml,json; json.dump(yaml.safe_load(sys.stdin), sys.stdout, indent=2)" < manifest.yaml

Who this guide is for

  • Convert a Kubernetes manifest to JSON for an API call to the cluster
  • Turn a Docker Compose file into JSON for programmatic inspection
  • Feed a YAML CI pipeline into a tool that only reads JSON
  • Inspect an ambiguous YAML value by seeing how it parses

Try the free JSON to YAML

Runs entirely in your browser — no upload, no signup, and your data never leaves your device.

Open JSON to YAML

Frequently Asked Questions

Is YAML to JSON lossless?

For ordinary configuration files, yes. Documents that rely on anchors, non-string keys, custom tags, or multiple documents in one file cannot be represented in JSON without change.

Why did my YAML comments disappear?

JSON has no comment syntax, so comments are dropped during conversion. Keep the YAML file as the source of truth if the comments matter.

Can I convert several YAML documents at once?

Convert them one at a time. A stream separated by --- has no single JSON equivalent — the usual answer is a JSON array assembled by hand from each result.

Tools mentioned in this guide

Related JSON Topics & Reference Articles