YAML to JSON Converter
Convert YAML to JSON online. Anchors and aliases are expanded, multi-document files become an array, and errors show their line and column. Runs in your browser.
How to use YAML to JSON
- 1Paste YAML into the input box, or open a .yaml or .yml file.
- 2Choose the JSON indent, or minify it, and sort keys if you want a stable order.
- 3Copy the JSON or download it as a .json file. Mode also offers JSON → YAML, Format, Minify, Validate and Tree for the same text.
What makes it better
- YAML 1.2 core schema: only true and false are booleans, not yes or no
- Anchors, aliases and multi-document files (---) are handled
- Alias expansion is capped to stop expansion bombs
- Custom tags and duplicate keys are reported, not guessed
- Switch to Format, Minify, Validate or Tree without leaving the page, with a validity line in every mode
About YAML to JSON
YAML to JSON reads YAML 1.2 using the core schema and writes standard JSON. Anchors and aliases are resolved, a file with several documents separated by --- becomes a JSON array, and alias expansion is capped so a malicious file cannot exhaust memory. Syntax errors, duplicate keys and custom tags are reported with the line and column where they occur, and the Mode switch adds JSON to YAML, Format, Minify, Validate and Tree views of the same text.
Common uses
- Read a Kubernetes or Docker Compose file as JSON so a script or jq can process it.
- Convert a YAML config into JSON for an API, a JavaScript app or a JSON-only tool.
- Expand anchors and merged defaults to see the final values a service will receive.
- Check what a multi-document YAML stream actually contains, one array item per document.
Example
Input
defaults: &defaults retries: 3 timeout: 30s service: name: billing settings: *defaults replicas: 2 released: 2024-01-15
Result
{
"defaults": {
"retries": 3,
"timeout": "30s"
},
"service": {
"name": "billing",
"settings": {
"retries": 3,
"timeout": "30s"
},
"replicas": 2
},
"released": "2024-01-15"
}Good to know
- Dates and timestamps are not converted, because the YAML 1.2 core schema treats them as text. A value such as 2024-01-15 appears as the string "2024-01-15".
- Custom tags such as !Ref or !include are rejected with an error instead of being guessed. Anchors and aliases are expanded, and a file that expands more than 100 aliases is refused.
- Comments are not part of the data, so they do not appear in the JSON. Whole numbers with more than 15 digits are read as JavaScript numbers and can lose precision.
YAML to JSON FAQ
How do I convert YAML to JSON?
Paste your YAML into the input box and the JSON appears next to it immediately. Choose an indent or minify, then copy or download the result. If the YAML has an error, a message tells you the line and column to fix, and Validate mode lists every problem together.
What happens to a YAML file with several documents?
Documents separated by a line containing three dashes are collected into one JSON array, with one item per document, and a notice tells you how many were found. A file with a single document produces that document directly.
Why is yes or no not turned into true or false?
Those spellings belonged to YAML 1.1. This tool follows YAML 1.2 with the core schema, where only true and false (in any common capitalisation) are booleans, so yes and no stay strings. That matches how most modern parsers behave.
What are anchors and aliases, and are they kept?
An anchor such as &defaults names a value and an alias such as *defaults reuses it. JSON has no such feature, so every alias is replaced by a full copy of the value it points to. The number of expansions is limited to protect your browser.
Why do I get an error about an unresolved tag?
Tags such as !Ref, !Sub or !include are extensions that only specific tools understand. Guessing at them would produce wrong data, and loading arbitrary types is unsafe, so the converter stops and points to the line with the tag.