YAML to JSON
Convert YAML to clean, indented JSON.
Overview
The YAML-to-JSON converter rewrites a YAML document into clean, indented JSON. Mapping keys become object properties, sequences become arrays, and scalars are typed according to YAML's resolution rules (integer, float, boolean, null, or string).
It's the bridge from YAML config (Kubernetes manifests, Helm values, GitHub Actions workflows, OpenAPI specs) to any JSON-consuming pipeline. Developers, DevOps engineers, and API designers reach for a yaml to json converter to feed YAML configs into tools that only speak JSON.
How it works
YAML 1.2 is a superset of JSON in terms of data model — every valid JSON document is also valid YAML. The converter parses the YAML, builds an in-memory tree, and serialises it as JSON with the chosen indentation. YAML-specific features that don't have a JSON peer are handled with conventions: anchors and aliases expand into duplicated nodes; multi-document streams produce a JSON array of documents; tagged scalars (!!str, !!int) honour the requested type.
YAML's implicit typing decides whether yes, 1.0, and null are booleans, floats, or null — the converter follows the 1.2 Core Schema rules, which are stricter than 1.1 and avoid most accidental coercion.
Examples
Input:
name: Alice
age: 30
tags:
- admin
- ops
address:
city: Berlin
Output:
{
"name": "Alice",
"age": 30,
"tags": ["admin", "ops"],
"address": { "city": "Berlin" }
}
With anchors:
defaults: &defaults
timeout: 30
production:
<<: *defaults
host: prod.example.com
{
"defaults": { "timeout": 30 },
"production": { "timeout": 30, "host": "prod.example.com" }
}
FAQ
What if my YAML has multiple documents?
Files with --- separators produce a JSON array, one element per document. That's the cleanest mapping since JSON has no native multi-document concept.
How are dates handled?
YAML's implicit date type (2024-01-15) parses to a date, but JSON has no date scalar, so it's serialised as an ISO 8601 string. Same for timestamp values with time and zone components.
Why is my unquoted "true" becoming a boolean?
YAML 1.2 reserves true, false, and null (plus ~ for null) as scalar literals. To keep them as strings, quote them explicitly in the source: value: "true".