Developer tools

YAML to JSON Converter

YAML to JSON Converter

Convert YAML to JSON and JSON to YAML, with anchors, multi-docs and safe quoting.

About this tool

About YAML to JSON Converter

Turn a YAML config into JSON for an API request, a test fixture or a tool that only reads JSON, or go the other way and turn JSON into tidy YAML for Kubernetes, docker-compose or a CI pipeline. The converter is a real YAML parser, not a find-and-replace: anchors and aliases are expanded, merge keys (<<) are applied, numbers, booleans and nulls become proper JSON types, and a file with several documents separated by --- becomes a JSON array. Errors come with the line and column, in both directions. When converting JSON to YAML, strings that some parsers would misread, such as yes, no, on, 12:30 or 007, are quoted, so the result means the same thing to PyYAML, Go and JavaScript readers alike. Choose 2 or 4 spaces, swap direction with one click to round-trip a file, and download the result. Conversion happens in your browser, so configuration secrets are never uploaded.

Built and maintained by Abhi JainUpdated

How to Convert YAML to JSON

  1. 1

    Pick the direction

    Choose YAML → JSON or JSON → YAML under Direction.

  2. 2

    Paste or open a file

    Paste your YAML or JSON into the left pane, open a file, or click Sample. Any error shows its line and column.

  3. 3

    Copy, download or swap

    Copy or download the converted output, or click Swap to convert it back the other way.

YAML to JSON Converter: questions and answers

What happens to YAML comments when converting to JSON?

They are dropped, because JSON has no comment syntax. If you need to keep them, keep the YAML file as the source of truth and generate JSON from it when needed.

How are anchors and aliases converted?

They are expanded: every *alias is replaced by a full copy of the anchored value, and merge keys (<<: *base) are merged into the map. JSON has no references, so this is the only faithful conversion.

What does a YAML file with several documents become?

A JSON array with one element per document, in the same order. A single document becomes a single JSON value.

Why are some strings quoted in the YAML output?

Values like yes, no, on, off, 1e3, 0x1F and 12:30 would be read as booleans or numbers by some YAML parsers. Quoting them keeps them as text everywhere.

Is YAML a superset of JSON?

YAML 1.2 is designed to be a superset of JSON, so almost any JSON document is already valid YAML. Converting to block-style YAML mostly makes it easier for people to read and edit.

Ready-made YAML to JSON Converter presets