YAML to JSON Converter
Parse YAML 1.2 into JSON with the error position when it fails and, when it succeeds, a report of every scalar whose type is version-dependent or that a numeric round trip rewrites — the mechanism behind most YAML production incidents.
JSON indentation
Parser edition
YAML 1.2 core schema. Divergence from YAML 1.1 is reported per scalar, never silently merged.
Anchors
Aliases and merge keys are expanded into concrete values, because JSON has no reference mechanism. 1 alias(es), 1 merge key(s) here.
YAML input
JSON output
{
"name": "orders-api",
"country": "NO",
"enabled": "off",
"version": 1.1,
"permissions": 17,
"duration": "12:30",
"when": "2025-01-07",
"single": "y",
"empty": null,
"quoted": "keep me a string",
"base": {
"replicas": 3,
"image": "registry.local/orders:1"
},
"prod": {
"replicas": 12,
"image": "registry.local/orders:1"
},
"list": [
"a",
"b"
],
"block": "line one\nline two\n"
}Parsed, with 6 value(s) whose type a YAML 1.1 reader would change
Plain scalars whose type is version-dependent, or that a numeric round trip rewrites
6 high risk, 1 worth a look, 0 same type in both editions but reprinted differently. A bare scalar is resolved by the reader, not written by you — quoting is the only way to pin it down.
| Line | Scalar as written | YAML 1.2 resolves | YAML 1.1 resolves | Risk | Why it matters |
|---|---|---|---|---|---|
| 3 | NO | "NO" | boolean false | high | YAML 1.1 resolves this to a boolean; the 1.2 core schema keeps it as a string. ISO 3166-1 alpha-2 codes (Norway = NO), feature flags written as on/off, and "Y" answers change type depending on which parser a project happens to pull in. |
| 4 | off | "off" | boolean false | high | YAML 1.1 resolves this to a boolean; the 1.2 core schema keeps it as a string. ISO 3166-1 alpha-2 codes (Norway = NO), feature flags written as on/off, and "Y" answers change type depending on which parser a project happens to pull in. |
| 5 | 1.10 | 1.1 | float 1.1 | medium | Version-like text such as "1.10" becomes the float 1.1: the trailing zero disappears, so "1.10" is written back as 1.1. Quote semantic versions and package versions. |
| 6 | 017 | 17 | integer 15 | high | A leading zero makes YAML 1.1 read "017" as octal (15). File modes such as 0755, zip codes and part numbers are the usual victims. Quote it, or write 0o755 for the 1.2 form. |
| 7 | 12:30 | "12:30" | integer (base 60) 750 | high | YAML 1.1 sexagesimal int: "12:30" becomes the integer 750 (base 60). Clock times and durations must be quoted. |
| 8 | 2025-01-07 | "2025-01-07" | timestamp Date object | high | YAML 1.1 parses the unquoted value "2025-01-07" into a timestamp, so exporters dump a Unix epoch or an ISO string with a time zone added — never the text you wrote. |
| 9 | y | "y" | boolean true | high | YAML 1.1 resolves this to a boolean; the 1.2 core schema keeps it as a string. ISO 3166-1 alpha-2 codes (Norway = NO), feature flags written as on/off, and "Y" answers change type depending on which parser a project happens to pull in. |
“Risk high” means the two spec editions resolve the same bare scalar to different values, so the meaning depends on which library your pipeline happens to use.
- Documents
- 1
- Top-level keys
- 14
- Anchors
- 1
- Aliases
- 1
- Merge keys
- 1
- Block scalars
- 1
- Flow nodes
- 0
- Explicit tags
- 0
- Multi-line strings
- 1
- Longest line
- 45
- Tab-indented lines
- 0
- Coerced scalars
- 7
Single document
None
Conversion plus a disclosure of what the parser decided
A YAML document is not a value; it is a set of instructions for producing one. Plain scalars are resolved against a schema, indentation carries structure, and anchors let one node appear in several places. Two readers on the same file can legitimately disagree, so this tool parses with YAML 1.2 rules and then lists the scalars whose resolution differs under YAML 1.1 — the values that will change meaning when an older library in the pipeline touches them.
Errors are positional. Tab indentation, a mapping value that is not a mapping, an inconsistent indentation level, an unresolved alias, a duplicate key, and a document that is actually several documents separated by --- each get a line and column with an explanation of the rule violated.
Structure is preserved on the way out: sequences stay sequences, nested maps stay nested maps, and block scalars become strings with their newlines intact. Anchors and aliases are expanded into repeated values, because JSON has no aliasing; the report says how many were expanded, since an anchor used for a merge key is a design decision someone should see in review.
What the YAML parser reports
- YAML 1.2 core schema resolution with 1.1 divergence flags
- Errors with line, column and the violated rule
- Tab-indentation and inconsistent-indentation detection
- Duplicate key reporting with both positions
- Multiple document (
---) recognition and count - Anchor, alias and merge key counts after expansion
- Block scalar and flow collection statistics
- Tag (
!!str,!!int) occurrences listed - JSON output with configurable indentation
- Structural summary of the resulting document
How to convert YAML to JSON
- 1Paste the YAMLManifests, workflows and compose files all work. If the file references external resources, only the local document is parsed — no fetches are performed.
- 2Fix positional errors firstTab characters in an indentation column are the single most common failure; the error names the line and explains that YAML indentation must be spaces.
- 3Read the implicit-typing tableEach row is a plain scalar, what it resolved to, what a YAML 1.1 reader would produce, and the risk level. High rows are the ones that change a string into a boolean or a number.
- 4Copy the JSONUse it in a pipeline step that expects JSON input, or continue to the JSON formatter to re-indent. Anchors are already expanded, so the JSON stands alone.
The divergences that matter
| Input | 1.2 core resolves to | 1.1 resolves to | Why it hurts |
|---|---|---|---|
NO | string "NO" | boolean false | Country code, answer column or flag becomes a boolean. |
off | string "off" | boolean false | A setting value that reads as false in one library and text in another. |
1.10 | float 1.1 | float 1.1 | A version string that loses its trailing digit in every reader. |
017 | string "017" | integer 15 | Permissions and identifiers silently become numbers. |
12:30 | string "12:30" | integer 750 | Times and durations reinterpreted as integers. |
2025-01-07 | timestamp | timestamp | Date becomes an object in some libraries, a string in others. |
y | string "y" | boolean true | Single-letter column values invert under 1.1. |
The fix in every row is the same on the way out: quote the value, or convert to JSON where a string is unambiguous — see the YAML guide.
Frequently asked questions
Does it parse YAML 1.1 or 1.2?
1.2 core schema, with a report of where a 1.1 reader would resolve a scalar differently. That report is the useful part: the version your toolchain uses is often invisible, and the divergence list shows exactly which values are at risk.
What is the Norway problem?
Under YAML 1.1 the plain scalar NO — the ISO country code for Norway — resolves to boolean false, so a list of country codes silently becomes a list of booleans. It is a name people use for the whole class of implicit-typing surprises; quoting is the cure.
Why is my YAML rejected because of tabs?
YAML forbids tab characters in the indentation column (spec 1.2 §6.1), because tab width is not defined by the format. Tabs inside a scalar value are fine; the parser tells you which line has the offending indentation.
What happens to anchors and merge keys?
They are expanded into the values they refer to, since JSON has no reference mechanism. The parser reports how many anchors, aliases and merge keys were present, so you can see that the JSON is a copy rather than a shared node.
Can it handle multi-document YAML?
It detects --- separators and reports the document count. JSON has no multi-document container, so the output is an array of documents with the count stated — which is also what a Kubernetes apply expects when a file holds several manifests.
Is YAML safe to parse from an untrusted source?
Only with a schema-limited parser. Historical deserialisation vulnerabilities in YAML libraries come from language-specific tags that construct objects — PyYAML’s yaml.load with its default loader is the standard example. Restrict to a safe or load API, which is why this tool only ever resolves to plain JSON values.
What does this report that a one-line parse call does not?
A failure arrives with a line, a column and the rule that was broken — tab indentation quoted to §6.1 and §8.4, an inconsistent sequence column, an unresolved alias, a duplicate key — rather than a truncated library message. On success it still reports: which plain scalars resolve differently under YAML 1.1 than under 1.2, how many anchors were expanded because JSON has no aliasing, and whether the file was really several documents behind --- separators.