YAML to JSON Converter

Paste YAML, such as a Kubernetes manifest or a CI config, and get the same data as formatted JSON.

Free tools that run in your browser. Nothing you type, open or create is uploaded to NerdBible or anyone else.

YAML

Converted in your browser with js-yaml (MIT licence). YAML comments, anchors and custom tags have no JSON equivalent, so comments are dropped and anchors are written out in full. A YAML file with several documents separated by --- becomes a JSON array.

How to use it

  1. Pick the format: YAML, XML, CSV, TSV or TOON. Then pick the direction, such as JSON to YAML or TOON to JSON.
  2. Paste your data. The result updates as you type, and an error shows its line and column.
  3. Set the options: indent and key order for YAML, the declaration and value types for XML, the delimiter, header row and quoting for CSV and TSV, or the delimiter and indent for TOON.
  4. Copy or download the result, or press Swap to convert it back.

Questions

Why does my YAML fail to convert?

The most common causes are tabs used for indentation, inconsistent indentation and a missing space after a colon. The error message gives the line and column to look at.

What happens to YAML comments?

They are removed, because JSON has no way to store comments.

Will yes and no become true and false?

No. The converter follows the YAML 1.2 core schema, where only true and false are booleans. Yes, no, on and off stay as strings.

About this tool

What the conversion does

YAML and JSON describe the same kinds of data: maps, lists, strings, numbers and booleans. The converter parses your YAML with js-yaml and writes the result as JSON with the indent you choose.

  • Errors point to the line. A tab used for indenting or a missing colon is reported with its line and column, so the converter doubles as a YAML validator.
  • Comments are dropped. JSON has no comments, so anything after a # disappears.
  • Anchors and aliases are expanded. A block reused with & and * is written out in full wherever it appears.
  • Several documents separated by --- become a JSON array with one item per document.

Watch the types

Values are read with the YAML 1.2 core rules: true and false are booleans, while yes, no, on and off stay as text. That avoids the classic surprise where the country code NO turned into false. Quote a value in the YAML when it must stay a string, such as a version number like 1.10.

Sort keys A to Z helps when comparing two files. Nothing is uploaded.

Related tools