What the converter does
This YAML to JSON converter reads a YAML document and writes the equivalent JSON as you type, entirely in your browser. Anchors and aliases are resolved, merge keys are applied, block scalars are turned into ordinary strings with the right newlines, and a file with several documents becomes a JSON array. When the input is not valid YAML, the error names the line, which is usually the only thing you need to find a stray tab or a missing space. Most ways to convert YAML to JSON online send the file to a server first; this one never does.
It is a real YAML parser, written for this page, not a regular expression pass. It covers what
configuration files actually use: block and flow mappings and sequences, plain, single-quoted and
double-quoted scalars with every escape, | and > blocks with the strip and keep indicators,
comments, anchors, aliases, the << merge key and --- document separators.
What it deliberately refuses
A partial YAML parser that silently returns something different is worse than none, so everything
outside the supported subset is an error, not a guess. Custom tags such as CloudFormation's !Ref
or !GetAtt stop the conversion, because their meaning lives in the application, not in YAML. So do
!!binary, complex keys written with ? or as a list, and the %TAG directive. The one tag that is
understood is !!str, which keeps 1.0 as text.
Numbers that JSON cannot hold exactly are refused too: .inf, .nan and integers beyond 2^53.
Quote them and they come through as strings, digit for digit.
YAML 1.2, not 1.1
Values are typed with the YAML 1.2 core schema. true, false and null (or ~, or nothing at
all) become JSON literals; 42, 0x1F, 0o17, 1.5 and 1e3 become numbers; everything else is a
string. That differs from PyYAML, which implements 1.1: there no is false, 0755 is octal, and
2026-09-23 becomes a date object. Here the first stays the text no, the second is the decimal
755, and the date stays a string, which is also how JSON would carry it. If a file must mean the
same thing to every parser, quote anything that could be read two ways.
YAML anchors and aliases
An anchor (&base) names a node and an alias (*base) repeats it. JSON has no references, so each
alias is expanded into a full copy, and a file that reuses one block ten times produces ten copies.
The merge key <<: *base copies the anchored mapping's keys into the current one; keys written
explicitly win over merged ones, and with <<: [*a, *b] the first source wins over the second. This
is the pattern Docker Compose files use for shared service settings, and it is where hand
conversion usually goes wrong.
Going the other way
To turn the JSON back into YAML, with quotes wherever YAML would misread a value, use the JSON to YAML converter. The JSON formatter will validate and re-indent the output, and the JSON diff shows what changed between two converted versions of the same config.