YAML to JSON Converter
Paste YAML on the left and get JSON on the right, instantly. The converter validates your YAML as you type, highlights the line of any error, and supports multi-document streams. Choose 2-space, 4-space, or minified output.
Related tools
How to convert YAML to JSON
- Paste or type your YAML into the left editor. You can also click Load sample to see an example.
- The JSON appears on the right immediately. Syntax errors in the YAML are reported below the editors with the line number.
- Pick an indentation style, then click Copy output or Download to save the file.
YAML to JSON mapping
YAML is a superset of JSON, so every YAML document maps cleanly onto JSON data types. This is how each construct is translated:
| YAML | JSON |
|---|---|
key: value mapping | Object { "key": "value" } |
- item block sequence | Array ["item"] |
[a, b] / {a: 1} flow style | Array / object |
123, 1.5, 1e3, 0x1F | Number |
true / false | Boolean |
null, ~, or empty value | null |
Multiline | and > blocks | String with \n escapes |
Anchors & and aliases * | Expanded in place (JSON has no references) |
# comments | Dropped |
Example
This YAML:
server:
host: 0.0.0.0
port: 8080
features:
- validator
- converter
becomes this JSON:
{
"server": {
"host": "0.0.0.0",
"port": 8080
},
"features": ["validator", "converter"]
}
Common gotchas
- Unquoted version numbers.
version: 1.10 is the float 1.1 in JSON. Quote it: version: "1.10". - Duplicate keys. The converter reports duplicate keys as an error rather than silently keeping the last one.
- Tabs. YAML forbids tabs for indentation. Replace them with spaces or run the input through the YAML formatter first.
- Colons in values.
time: 12:30 is fine, but url: http://x without quotes can be misread in some contexts. When in doubt, quote strings that contain : or #.
Need to check your YAML without converting it? Use the
YAML validator. Going the other direction? Try the
JSON to YAML converter.
Frequently asked questions
Is my YAML uploaded anywhere?
No. The conversion runs entirely in your browser using the js-yaml library. Nothing you paste leaves your machine, so it is safe to use with configuration that contains secrets.
What happens to comments when converting YAML to JSON?
JSON has no comment syntax, so comments are dropped. Everything else, including nested maps, lists, numbers, booleans, and null values, is preserved.
How are multiple YAML documents handled?
If the input contains several documents separated by ---, the output is a JSON array with one element per document.
Why did my date turn into a string?
YAML has a native timestamp type but JSON does not. Dates such as 2024-01-15 are converted to ISO 8601 strings like "2024-01-15T00:00:00.000Z". Quote the value in YAML if you want it kept exactly as written.
Which YAML version is supported?
The converter follows YAML 1.2 core schema. That means yes and no stay strings and only true/false become booleans, which matches most modern parsers.