Convert YAML to JSON, including multi-document files and anchors
Convert YAML (Kubernetes, Compose, OpenAPI, CI) to JSON. Indentation mistakes are reported with the line and column.
How to use it
Paste YAML on the left, or open a .yml/.yaml file. If the YAML has a mistake, the result names its line and column; Show in input puts the cursor there. Pick the JSON indent: 2, 3 or 4 spaces, a tab, or Minified for one line. Copy or download the JSON.
Examples
Compose service to JSON
Input
api:
image: node:22
ports:
- "3000:3000"Result
{
"api": {
"image": "node:22",
"ports": [
"3000:3000"
]
}
}Several documents
Input
kind: Service --- kind: Deployment
Result
[
{
"kind": "Service"
},
{
"kind": "Deployment"
}
]A file with several --- documents becomes a JSON array.
YAML details that change values
Anchors and aliases (&base, *base, <<: *base) are expanded into full copies. This converter follows YAML 1.2: yes/no/on/off stay strings; only true and false are booleans. Unquoted values like 1.10 become numbers (1.1). Quote version strings: "1.10". 0755 becomes the number 755: YAML 1.2 writes octal as 0o755. Quote file modes that must stay as written. Dates such as 2024-01-01 stay strings. .inf and .nan stop with a message, because JSON has no such numbers. Very large integers keep every digit in the JSON output.
Questions
- Why does my YAML fail to parse?
Most often it is indentation: mixing tabs and spaces, or a list item not lined up under its parent. The error shows the line and column where the parser gave up. - Can it convert a file with several documents?
Yes. Documents separated by --- become items of a JSON array, in order. - Is my config uploaded?
No. Everything runs in your browser, so your config stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. Kubernetes manifests, CI files and .env-style configs often hold secrets, and the page warns you if it spots any.