YAML to JSON Converter
Bidirectional YAML ⇄ JSON converter — convert YAML to JSON or JSON to YAML, live, in your browser.
Free online YAML to JSON converter and JSON to YAML converter in one tool — paste either format, pick a direction, and get clean, correctly-typed output instantly. Adjustable JSON indent width and YAML block/flow style. No data ever leaves your browser.
Direction
JSON indent
YAML style
Quick reference
- key: value
- →
{"key":"value"} - - a
- b - →
["a","b"] - ~ / null
- →
null - All JSON
- is valid YAML
YAML vs JSON — what's the difference?
JSON (JavaScript Object Notation) is a strict, compact data format built from braces {}, brackets [], and quoted strings. It's fast and unambiguous to parse, which is why it's the default format for HTTP APIs, databases, and JavaScript's JSON.parse / JSON.stringify.
YAML (YAML Ain't Markup Language) is a superset of JSON — every valid JSON document is also valid YAML — but adds a more human-friendly syntax on top: indentation instead of braces, no required quotes around simple strings, inline # comments, and block scalars for multi-line strings. That's why YAML is the format of choice for files people hand-edit: Docker Compose, Kubernetes manifests, GitHub Actions workflows, Ansible playbooks, and CI/CD pipelines.
Because YAML is a JSON superset, converting JSON to YAML always succeeds and never loses information. Converting YAML to JSON can only fail if the YAML uses a feature JSON has no equivalent for — comments are simply dropped, since JSON has no comment syntax.
How to convert YAML to JSON
Switch this tool to YAML → JSON mode, paste your YAML document into the input, and the equivalent JSON appears instantly on the right. Under the hood: js-yaml parses the YAML into a native JavaScript object (resolving anchors, aliases, and type tags along the way), and JSON.stringify serializes that object back out as JSON with your chosen indent width.
// Node.js
const yaml = require('js-yaml');
const fs = require('fs');
const doc = yaml.load(fs.readFileSync('config.yaml', 'utf8'));
console.log(JSON.stringify(doc, null, 2));
# Python
import yaml, json
with open('config.yaml') as f:
doc = yaml.safe_load(f)
print(json.dumps(doc, indent=2))
How to convert JSON to YAML
Switch this tool to JSON → YAML mode, paste your JSON, and pick block style (the common, one-key-per-line convention) or flow style (compact, JSON-like brackets) for the output. Under the hood: JSON.parse turns the JSON text into a JavaScript object, and js-yaml's dump() function serializes it as YAML.
// Node.js
const yaml = require('js-yaml');
const fs = require('fs');
const doc = JSON.parse(fs.readFileSync('data.json', 'utf8'));
console.log(yaml.dump(doc));
# Python
import yaml, json
with open('data.json') as f:
doc = json.load(f)
print(yaml.dump(doc, default_flow_style=False))
When to use this converter
- Migrating configs — turning a Docker Compose or Kubernetes YAML manifest into JSON for a tool that only accepts JSON config, or the reverse when adopting a YAML-based CI system.
- Debugging API responses — some APIs return YAML; converting to JSON makes it easier to feed into
jq, browser dev tools, or a JSON schema validator. - Writing config by hand — draft in JSON (strict, IDE-autocompletes cleanly) then convert to YAML for the final file, or the reverse to check a hand-written YAML file parses into the object shape you expect.
- Learning YAML — seeing the JSON equivalent of a YAML snippet is one of the fastest ways to understand what a block of indentation actually means.
Working with JSON specifically? Try the JSON formatter to pretty-print or minify, or JSON to CSV to flatten records into a spreadsheet. For XML config files, see the XML formatter.
Frequently asked questions
&anchor / *alias) are resolved and expanded to their full values on input; JSON to YAML output does not re-introduce anchors, so the result is always plain, unambiguous YAML.