YAML to JSON
Convert YAML into JSON and surface indentation or syntax errors with line numbers.
YAML to JSON tool
What this tool does
Paste YAML and get JSON, with anchors expanded, block scalars folded into strings and
multi-document streams turned into an array — one element per --- section. When
the YAML does not parse, you get the line number, the column and the parser's own pointer
under the offending character, plus an explanation of what that error usually means.
Parsing uses js-yaml's default schema, which supports the standard tags only. No tag in a pasted document can construct a JavaScript object, call a function or touch anything outside this page.
Common uses
- Feeding a Kubernetes manifest, a Compose file or a CI config to a tool that only reads JSON.
-
Finding the indentation mistake in a 400-line
values.yamlthat a CI job rejected with an unhelpful message. - Checking what a chain of
&anchorand*aliasreferences actually expands to. - Reading OpenAPI or AsyncAPI specifications with JSON-oriented tooling.
- Converting front matter into data for a script.
A short example
This YAML, with an anchor and an alias:
limits: &res
cpu: 500m
memory: 512Mi
requests: *res becomes JSON with the value written out twice:
{
"limits": { "cpu": "500m", "memory": "512Mi" },
"requests": { "cpu": "500m", "memory": "512Mi" }
} Values that change type on the way through
YAML infers types from unquoted text, and the rules differ between YAML 1.1 and 1.2. This converter follows the 1.2 core schema. Four cases are worth checking in your own files:
- Dates become strings.
when: 2026-09-24is a timestamp in YAML, so it arrives in JSON as"2026-09-24T00:00:00.000Z"— a full UTC instant, not the date you typed. Quote it to keep the original text. - Leading zeros are decimal here.
010converts to10. A YAML 1.1 parser such as PyYAML or Go'syaml.v2reads the same text as octal8. -
yes,no,onandoffstay strings under the 1.2 core schema. Under 1.1 they are booleans — the reason a country code ofNOfamously turns intofalsein some pipelines. - Version numbers lose a digit.
1.10is the float 1.1. Always quote versions.
Worth knowing
Two things are rejected rather than guessed at. A tab character used for indentation is an error in YAML at any version — the spec allows tabs inside a scalar but never as indentation — and a key repeated inside the same mapping is refused here, because silently keeping the last value is how a config change disappears without trace. Comments are discarded, since JSON has nowhere to put them. And if a stream contains several documents, converting with First only deliberately drops the rest; the default wraps them in an array so nothing is lost.
Frequently asked questions
Why does a Helm chart fail with a strange indentation error?
Because {{ opens a flow mapping in YAML. A line such as name: {{ .Release.Name }} is read as a nested mapping and reports bad indentation of a mapping entry at a column that looks perfectly fine, which sends people hunting for spaces that were never wrong. Render the chart first with helm template, or quote the expression in the chart — good practice there in any case.
What does an empty value convert to?
The null node. A key with nothing after the colon, a ~, and null in any capitalisation all become JSON null, whereas "" is an empty string and None stays the three-letter text — Python habits do not carry over. Write the quotes explicitly when a field must be empty rather than absent, since a truthiness check treats the two identically but a schema will not.
Are merge keys expanded?
Yes. <<: *defaults pulls the keys of the aliased mapping into the current one and the JSON shows the merged result with no trace of the marker; keys written alongside the merge win over the ones it brings in. It is a YAML 1.1 feature that the 1.2 specification dropped, so a strict 1.2 parser may hand you a literal << key instead — do not rely on it in files that unfamiliar tooling reads.