Convert YAML to JSON
Paste your YAML into the left box. The JSON is shown on the right as you type. Choose the indent, or minified output with no spaces, and copy the result or download it as a file.
# YAML
name: demo
ports: [80, 443]
debug: false
// JSON
{
"name": "demo",
"ports": [80, 443],
"debug": false
}
How YAML values become JSON
| In YAML | In JSON |
|---|---|
| A mapping | An object |
| A sequence | An array |
| true, false | true, false |
| null, ~ or an empty value | null |
| Numbers such as 42 and 3.14 | Numbers |
| Text, quoted or plain | Strings |
| A block scalar with | or > | A string, with line breaks for | |
| An alias such as *name | A copy of the anchored value |
Anchors and merge keys
YAML lets you define a value once with an anchor, such as &defaults, and reuse it with an alias, *defaults. JSON has no such feature, so the converter writes out the full value wherever an alias was used. With Resolve merge keys turned on, an entry written <<: *defaults is merged into its mapping, as it is by most tools.
Several documents
A YAML file can hold several documents separated by three dashes, and a JSON file holds only one value. With several documents, the result is an array with one item for each document. Tick Always return an array to get an array even for a single document.
What is lost or changed
- Comments have no place in JSON and are dropped.
- Very large numbers are rounded, because JSON numbers in JavaScript are limited to about 15 digits of exactness. The tool warns you.
- Infinity and not-a-number values, written as .inf and .nan in YAML, cannot be written in JSON and become null.
Syntax errors in the YAML are shown with the line and column. To go the other way, use JSON to YAML. To check a file without converting it, use the YAML validator. For help with the language, see the YAML syntax guide.