Quick answer
A YAML-to-JSON converter parses YAML's indentation-based structure into a data tree and serializes it as JSON: mappings become objects, sequences become arrays, and scalars keep their types. This tool uses the js-yaml 4 parser (YAML 1.2 core schema) and outputs 2-space-indented JSON entirely in your browser — nothing is uploaded. Paste YAML, click Convert to JSON, then copy or download.
How This Tool Converts YAML to JSON
- YAML key-value pairs become JSON object properties — each
key: valueline maps directly to"key": valuein the JSON output. - YAML sequences (lines prefixed with
-) become JSON arrays. Each list item becomes one array element, preserving order. - YAML strings, integers, floats, booleans (
true/false), andnullare converted to their equivalent JSON types — the conversion is type-safe and lossless for standard YAML. - YAML anchors (
&name) and aliases (*name) are resolved during parsing. The output JSON contains the fully expanded values; anchor references are not preserved in the output. - Indented YAML blocks become nested JSON objects, with each indentation level corresponding to one level of nesting in the JSON output.
When to Use YAML to JSON
- When an API, database, or tool only accepts JSON payloads but your source config is a YAML file (Kubernetes manifest, Docker Compose, Ansible playbook).
- When you want to inspect or query Kubernetes or Helm values with a JSON-aware tool like JSONPath Tester or
jq. - When a CI/CD pipeline outputs YAML and you need to extract specific values programmatically using a JSON parser.
- When migrating infrastructure-as-code from YAML-based tooling to a JSON-accepting pipeline or configuration system.
Worked example
A small config that shows how each YAML type maps to JSON — and one value that's easy to get wrong:
Input YAML
name: John Smith
port: 8080
enabled: true
country: NO
roles:
- admin
- editor
Output JSON
{
"name": "John Smith",
"port": 8080,
"enabled": true,
"country": "NO",
"roles": [
"admin",
"editor"
]
}
What happened
- An unquoted string with spaces (
John Smith) became a JSON string — YAML doesn't require quotes around most strings. port: 8080became the number8080andenabled: truebecame the booleantrue— YAML scalar types map straight to JSON types.- The
rolessequence became a JSON array, indentation replaced by brackets. country: NOstayed the string"NO"— because this tool's YAML 1.2 parser does not treatNOas a boolean. A YAML 1.1 parser would have turned it intofalse(see gotchas).
Edge cases & gotchas
- Parser version changes the result. This tool uses js-yaml 4 (YAML 1.2 core schema), so
yes,no,on,offstay strings. Under YAML 1.1 — still used by many tools — those become booleans (the "Norway problem", whereNObecomesfalse). Don't assume your downstream system parses the same way; quote values you need to stay strings. - Anchors and aliases are expanded. A value defined with
&anchorand reused via*aliasis resolved to its full value in the JSON, so a value referenced three times appears as three copies — the reference itself is not preserved. - Comments are dropped. YAML
#comments carry no data and JSON has no comment syntax, so they disappear in the output. - Only one document at a time. Multi-document YAML separated by
---isn't supported here — split it and convert each document separately. - Very large integers can lose precision. A number beyond JavaScript's safe integer range (about 9 quadrillion) may be rounded, because the value passes through a JS number on the way to JSON.
Frequently Asked Questions
Can I convert Kubernetes YAML to JSON?
Yes. Paste any Kubernetes manifest, Helm values file, or Docker Compose YAML and the tool converts it to JSON, preserving all nested objects, arrays, and data types.
Does YAML to JSON preserve data types?
Yes. YAML strings → JSON strings, integers and floats → JSON numbers, true/false → JSON booleans, null → JSON null. The conversion is type-safe.
Is my YAML data sent to a server?
No. All conversion happens entirely in your browser. Your data never leaves your device.
What happens to YAML anchors and aliases?
Anchors (&name) and aliases (*name) are resolved during parsing. The output JSON contains the fully expanded values — the anchor references themselves are not preserved. If a value is referenced via three aliases, it will appear as three copies in the JSON output.
Does this tool handle multi-document YAML?
This tool converts a single YAML document at a time. Multi-document YAML files that use --- as a separator should be split into individual documents before converting each one separately.
Does this tool turn yes/no/on/off into booleans?
No. This converter uses the js-yaml 4 parser, which follows the YAML 1.2 core schema — only true and false are booleans, so yes, no, on, and off stay strings. Be aware that many other tools still use YAML 1.1, where those words do become booleans (the famous "Norway problem", where the country code NO becomes false). If your downstream system uses a YAML 1.1 parser, quote those values to keep them as strings.
What happens to YAML comments?
They are dropped. YAML comments start with # and carry no data, and JSON has no comment syntax, so there is nowhere for them to go. Only the actual keys, values, and structure survive the conversion.