Output appears here.
YAML to JSON parses YAML — including anchors, aliases and multi-document files — and prints it as formatted JSON. Use it to feed a Kubernetes manifest, a Compose file or a CI config into a script, an API or jq, or to see exactly which types YAML assigned to your values. It runs in your browser; nothing is uploaded.
How to convert YAML to JSON
- Paste YAML, drop a
.yamlor.ymlfile, or press ⌘/Ctrl O. - Choose an Indent for the JSON and decide how files with several
---documents should be handled with Multiple documents as array. - Copy the JSON with ⌥/Alt C or download it with ⌘/Ctrl S. Next actions open it in the JSON Formatter, send it back to YAML, or — when the result is a list of objects — convert it to CSV.
Examples
Anchors and aliases
A list defined once with ®ions and reused with *regions. Aliases are expanded, so every reference receives a full copy.
regions: ®ions
- ap-south-1
- eu-west-1
web:
replicas: 3
regions: *regions
worker:
replicas: 1
regions: *regionsResult:
{
"regions": [
"ap-south-1",
"eu-west-1"
],
"web": {
"replicas": 3,
"regions": [
"ap-south-1",
"eu-west-1"
]
},
"worker": {
"replicas": 1,
"regions": [
"ap-south-1",
"eu-west-1"
]
}
}Merge keys
A database.yml-style file where each environment merges shared defaults with <<: *defaults. The merged keys are copied into each mapping, and a key written locally, such as pool: 20, overrides the merged value.
defaults: &defaults
adapter: postgres
pool: 5
development:
<<: *defaults
database: app_dev
production:
<<: *defaults
pool: 20
database: appResult:
{
"defaults": {
"adapter": "postgres",
"pool": 5
},
"development": {
"adapter": "postgres",
"pool": 5,
"database": "app_dev"
},
"production": {
"adapter": "postgres",
"pool": 20,
"database": "app"
}
}How YAML types your values
Unquoted values are typed by YAML's rules, and the JSON makes that visible. Note 1.10 becoming 1.1 and the ZIP code losing its leading zero.
version: 1.10
zip: 07302
country: NO
port: 8080
timeout:
release: 2026-09-26Result:
{
"version": 1.1,
"zip": 7302,
"country": "NO",
"port": 8080,
"timeout": null,
"release": "2026-09-26"
}Two Kubernetes documents, 4-space indent
With Multiple documents as array on, each --- document becomes one element of a JSON array.
kind: Service
metadata:
name: web
---
kind: Deployment
metadata:
name: webResult:
[
{
"kind": "Service",
"metadata": {
"name": "web"
}
},
{
"kind": "Deployment",
"metadata": {
"name": "web"
}
}
]Options explained
- Indent — the whitespace used for each nesting level in the JSON output: 2 spaces, 4 spaces or a tab.
- Multiple documents as array — when the YAML contains several
---documents, returns them all as a JSON array; when off, only the first document is converted and a notice says how many were skipped.
Troubleshooting YAML to JSON
Numbers and versions come out wrong
YAML reads unquoted 1.10 as the number 1.1 and 07302 as 7302. Quote values that must stay text — version numbers, ZIP and phone codes, IDs with leading zeros — in the YAML source: version: "1.10". Large integers are not affected: an ID such as 12345678901234567890 keeps every digit in the JSON.
An empty value became null
timeout: with nothing after the colon is null in YAML, not an empty string. Write timeout: "" if you need an empty string in the JSON.
.inf or .nan became null
JSON has no Infinity or NaN, so YAML's .inf, -.inf and .nan are written as null, and a notice says how many values were affected: "JSON has no Infinity or NaN — 2 values were written as null." Use a very large number or a string if the consumer needs to tell them apart.
"Map keys must be unique"
The same key appears twice in one mapping. JSON objects cannot represent that reliably, so the converter stops at the second occurrence. Delete or rename one of them.
Indentation and tab errors
Messages such as "All mapping items must start at the same column" or "Tabs are not allowed as indentation" point to a whitespace problem on the given line. Fix it in the YAML Formatter, or read the YAML indentation guide.
Only part of my file was converted
The file has several documents separated by --- and Multiple documents as array is off. Turn it on to get every document.
FAQ
Is it safe to convert files that contain secrets?
Yes. Kubernetes Secrets, .gitlab-ci.yml variables and Helm values often hold credentials, and none of it leaves your device. The converter runs in your browser inside an isolated frame that blocks network requests, and nothing is stored on a server. Your settings are remembered locally; the input is kept only if you turn on "Remember my last input".
Are comments kept in the JSON?
No. JSON has no comment syntax, so every YAML comment is dropped during conversion. If you need to keep annotations, store them as ordinary keys such as "description", or keep the YAML as the source of truth and generate the JSON from it when needed.
Is "NO" converted to false?
No. This converter uses YAML 1.2, where only true and false are booleans, so NO, yes, on and off stay strings. Tools that still follow YAML 1.1 treat them as booleans — the well-known Norway problem — so quoting them in shared files is still good practice.
What happens to dates?
Dates such as 2026-09-26 are kept as strings exactly as written, not converted to timestamps. That matches what most JSON consumers expect: an ISO 8601 string they can parse themselves, with no time zone assumptions added.
How are anchors and aliases handled?
Each alias is replaced by a full copy of the anchored value, because JSON has no references, and << merge keys are resolved into their parent mapping. A value reused many times therefore appears many times in the output, which can make the JSON noticeably larger than the YAML it came from.
Can I convert a multi-document file into separate JSON files?
The converter produces one JSON value: either an array of all documents, or the first document only. To get separate files, convert with Multiple documents as array on and copy each array element, or split the YAML at the --- lines and convert each part.
Related tools
To go the other way, use JSON to YAML. The guide JSON vs YAML explains the typing rules shown above in more detail. For TOML config, see TOML to JSON.
Related tools
Guides
- JSON vs YAML: When to Use Which — When should I use JSON and when YAML?