YAML to JSON
YAML mappings become JSON objects, dashed lists become arrays, and bare words are typed: 8080 is a number, false a boolean. The conversion is lossless for data; comments and anchors are dropped.
Last reviewed 2026-11-04.
Supported: block maps and lists, flow [ ] and { }, quoted and plain scalars, | and > blocks, comments. Not supported: anchors, aliases, tags, merge keys, multi-line quoted or flow values and multiple documents. These are reported as errors, never silently changed.
Worked example
$ name: web
port: 8080
tags:
- a
- b
debug: false
version: 1.10
country: NO
becomes
{
"name": "web",
"port": 8080,
"tags": [
"a",
"b"
],
"debug": false,
"version": 1.1,
"country": "NO"
}Gotchas
version: 1.10is the number 1.1 in YAML. Quote it ("1.10") to keep the trailing zero.country: NOis the string "NO" in YAML 1.2, which this tool follows. YAML 1.1 parsers (older PyYAML, many Ruby tools) read it as boolean false.- Indentation is the structure, and tabs are not allowed for it.
- Comments (
# note) have no JSON equivalent and are lost on conversion.
JSON to YAML
The reverse works the same way. {"a":[1,2],"b":{"c":null}} becomes:
$ a:
- 1
- 2
b:
c: nullRunning this on a server
YAML and JSON config files usually end up on a server or in CI. The hosting guide compares places to run small services.
Frequently asked questions
Is YAML a superset of JSON?
Since YAML 1.2, valid JSON is valid YAML, so a JSON file parses as YAML.
Why did my value change type?
Unquoted scalars are typed by their look: 1.10 is a number, true a boolean, null a null. Quote it to force a string.
Are comments kept?
No. JSON has no comments.
Sources
- YAML 1.2.2 specification checked 2026-11-04
- RFC 8259: The JSON Data Interchange Format checked 2026-11-04