Converters
YAML to JSON Converter
Full YAML 1.2 parsing — anchors resolved, types preserved, errors pinpointed — straight into clean JSON.
In short
Convert YAML to JSON online: full YAML 1.2 parsing with anchors resolved and exact error positions, output at your chosen indentation. Free and private.
By NaveenKumar T · Updated
Learn: TOML vs YAML vs JSON: Choosing a Configuration Format
- Instant in-browser conversion
- Validates input first
- Anchors & aliases fully resolved
Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →
Example
YAML to JSON: input and output
A compose-style service file that leans on an anchor, a hex literal, a comment, a YAML 1.1-style boolean word and a bare date — everything YAML lets you write that JSON cannot.
defaults: &defaults
restart: unless-stopped
memory: 0x200 # 512 MiB
services:
api:
image: ghcr.io/acme/api:1.10
ports: [8080, 8443]
options: *defaults
healthy: yes
worker:
image: ghcr.io/acme/worker:1.10
options: *defaults
replicas: 3
started: 2026-06-03
owner: ~{
"defaults": {
"restart": "unless-stopped",
"memory": 512
},
"services": {
"api": {
"image": "ghcr.io/acme/api:1.10",
"ports": [
8080,
8443
],
"options": {
"restart": "unless-stopped",
"memory": 512
},
"healthy": "yes"
},
"worker": {
"image": "ghcr.io/acme/worker:1.10",
"options": {
"restart": "unless-stopped",
"memory": 512
},
"replicas": 3,
"started": "2026-06-03",
"owner": null
}
}
}Both *defaults aliases were expanded into full copies of the anchored mapping, 0x200 became 512 and the comment vanished. Under YAML 1.2 rules, yes and 2026-06-03 stayed strings rather than becoming a boolean or a date, while ~ became null and the flow sequence [8080, 8443] became a JSON array of numbers.
Learn more
How YAML to JSON conversion works
The converter runs a complete YAML 1.2 parse: mappings become objects, sequences become arrays, and scalars resolve to their real types (strings, numbers, booleans, null). YAML-only conveniences are normalized away — anchors and aliases are expanded to their actual values, multi-line block scalars become escaped strings, and comments are dropped, since JSON has no equivalent.
Syntax errors report the precise line and column — indispensable in YAML, where a single misplaced indent changes the document's meaning.
When to convert YAML to JSON
The reverse of the cloud-config flow: your source of truth is YAML (Kubernetes manifests, CI pipelines, OpenAPI specs) but a tool demands JSON — a RESTAPI body, a JavaScript import, a JSON-schema validator. Converting here also doubles as a YAML sanity check: if the JSON looks wrong, your YAML's indentation probably was too.
Help
Frequently asked questions
Everything you need to know about the YAML to JSON.
01Can I convert a Kubernetes manifest that contains several documents?
Not in one paste: a stream with --- separators is rejected by the parser with the position of the second document. Convert each document separately, or split the file on --- first. Everything else Kubernetes manifests use — anchors, merge keys, block scalars, quoted numbers — converts as described in the FAQs below, with <<: merge keys kept as a literal << key rather than expanded.
02What happens to YAML comments and anchors in JSON?
Comments are removed — JSON cannot represent them. Anchors (&ref) and aliases (*ref) are resolved by value: every alias is replaced with a full copy of the anchored content, so the JSON is self-contained and parses identically everywhere.
03Which YAML scalars change type on the way to JSON?
Parsing uses the YAML 1.2 core schema: true, false, null and ~ become their JSON counterparts, an empty value becomes null, and 0x1F and 0o17 become 31 and 15. yes, no, on and off stay strings (booleans only in YAML 1.1), and dates like 2026-06-03 stay strings too — nothing becomes a Date. .inf and .nan have no JSON form and are written as null. Merge keys (<<: *base) are not expanded; the << key is kept with the aliased mapping as its value. Multi-document files (---) are rejected.
04Does JSON to YAML on the result give me back the original YAML file?
The data matches exactly — every value this parser resolved is written back to an equivalent YAML scalar — but source-specific formatting does not: anchors and aliases arrive already expanded, so a file that used &defaults and *defaults to avoid repetition comes back as several full, independent copies of that block rather than a shared reference. Comments are gone, for the same reason JSON has none to carry them.
Keep working
Related tools
JSON to YAML
Converters
YAML to XML
Converters
YAML to CSV
Converters
JSON Formatter
Format, beautify, and validate JSON instantly in a professional VS Code-style editor — free, fast, and 100% private.
YAML to Properties
Converters
Docker Compose Validator
Syntax, schema and cross-reference errors in one report — catch a broken compose file before docker compose up does it for you.
Learn the format
Related guides
TOML vs YAML vs JSON: Choosing a Configuration Format
TOML, YAML and JSON compared for configuration files: comments, types, nesting, dates, tooling and the ecosystems that chose each — with a decision guide and conversions.
6 min readGuide · Data FormatsYAML Multi-line Strings: | vs > vs Quoted (Indentation Rules)
How YAML literal | and folded > block scalars differ, what -, + and a digit change, when to quote instead, and why a run: block loses its line breaks.
9 min readGuide · Data FormatsYAML Anchors, Aliases and Merge Keys Explained (With Real Config Examples)
How &anchor, *alias and the <<: merge key work in YAML, where docker-compose, GitLab CI and Helm use them, the override order, and the errors they cause.
7 min read