YAML to JSON

Convert YAML to formatted or minified JSON in your browser. Multi-document files become an array; comments dropped, anchors expanded. Free.

Or drop a file hereYAML
Result

About YAML to JSON

YAML to JSON converts YAML configuration, such as CI, Docker or Kubernetes files, into JSON. Pick pretty-printed or minified output and copy or download it.

Multi-document files

Files with several documents separated by --- become a JSON array, one item per document.

Anchors and comments

Anchors and aliases are expanded into full values. Comments are dropped, because JSON has no comments.

Sort keys

Tick Sort keys alphabetically for tidy, easy-to-compare output.

YAML 1.2 rules

The word yes stays a string, not true. Older YAML 1.1 programs may read the same file differently.

Clear errors

Broken YAML shows the reason and the position, so you can fix it quickly.

Private

Your data is processed in your browser. Nothing is uploaded.

Why convert YAML to JSON?

Many APIs, tools and programming languages read JSON natively. Seeing the JSON also shows exactly how the YAML indentation was understood.

How to use YAML to JSON

  1. Paste your YAML or open a file.
  2. Choose 2 spaces, 4 spaces or Minified, and tick Sort keys if you want them sorted.
  3. Press Convert.
  4. Copy the JSON or download the .json file.

Help & FAQ

What does YAML to JSON do?

It converts YAML text or a file into JSON, formatted with two or four spaces or minified, and can sort the keys.

What happens to a file with several documents?

Documents separated by --- become a JSON array. In the test a: 1 and b: 2 became [{a:1},{b:2}].

Are comments kept?

No. JSON has no comments, so they are dropped in the conversion.

Are anchors and aliases expanded?

Yes. In the test an alias key received a full copy of the anchored object.

Why did .inf and .nan become null?

JSON cannot represent infinity or not-a-number, so the tool writes null for them.

Why did our long number change?

Numbers are read as ordinary JavaScript numbers, so 12345678901234567890 became 12345678901234567000. Quote such values in the YAML to keep them exact.

Is yes converted to true?

No. In the test yes stayed the string yes. Older YAML 1.1 parsers would give true, so check your own program.

Can we get minified JSON?

Yes. Choose Minified in the Indent list and the result is written on one line.

What does an invalid file show?

It shows Invalid YAML with the reason and a line and column, and produces no JSON.

Does it sort keys at every level?

Yes. In the test the top-level keys and the keys inside a nested mapping were both sorted.

Is our YAML uploaded?

No. The conversion runs in your browser and the text is not sent to a server.

More in Office & Data

See all 28 in Office & Data