Quick access

Saved in this browser. Sign in to keep it on all your devices.

YAML to JSON Converter

Convert YAML to JSON and vice versa instantly.

Error:

Input (YAML)
Output ()
Lines: Size:

Features

  • Convert YAML to JSON
  • Convert JSON to YAML
  • Auto-convert on input
  • Proper 2-space indentation

YAML Example

# Config file
database:
  host: localhost
  port: 5432
  users:
    - admin
    - guest

cache:
  enabled: true
  ttl: 3600
Version 1.1 Updated What's new

Release notes

  1. v1.1 Latest
    • Added an in-depth guide below the tool, written from what the tool actually does.
    • Now uses a full YAML parser (js-yaml), so nested lists, anchors and multi-line strings convert correctly.

About the YAML to JSON Converter

YAML and JSON describe the same kinds of data. YAML is easier for people to write, such as in Docker Compose or Kubernetes files, while JSON is what most APIs and programs read.

How to use it

  1. 1 Paste YAML or JSON into the input.
  2. 2 Choose the direction to convert.
  3. 3 Fix any reported syntax error, then copy the output.

Frequently asked questions

Is all YAML valid JSON?

No, but all JSON is valid YAML 1.2. YAML adds comments, anchors, and multi-line strings, which have no direct JSON equivalent.

Are YAML comments kept?

No. JSON has no comments, so they are dropped when converting from YAML to JSON.

Why does my YAML fail to parse?

The most common causes are tabs instead of spaces for indentation, inconsistent indentation, and a missing space after a colon.

The same data in both formats

# YAML
server:
  host: localhost
  ports:
    - 80
    - 443

{"server":{"host":"localhost","ports":[80,443]}}

YAML uses indentation where JSON uses braces and brackets. This converter parses input with js-yaml, a widely used library that follows YAML 1.2, so nested maps, lists of objects, block text and flow syntax such as [1, 2] all work. Parsing happens in your browser.

What has no JSON equivalent

  • Comments are discarded because JSON cannot hold them, so a round trip through JSON loses them for good.
  • Anchors and aliases are expanded into full copies of the data.
  • A date like 2026-11-11 is read as a timestamp and comes out as a full ISO string. Put it in quotes to keep it as written.
  • A file with several documents separated by --- is rejected, because JSON has a single root. Convert one document at a time.

The Norway problem

YAML 1.1 read unquoted yes, no, on and off as booleans. A list of country codes containing NO would quietly turn Norway into false. YAML 1.2 limits booleans to true and false, and this converter follows it, so no stays a string here. Other software may not: PyYAML and parts of the older Ruby and Go ecosystems still apply 1.1 rules. Quote any value that could be misread.

Numbers have similar traps. A version like 1.10 parses as the number 1.1, and a ZIP code like 01234 can lose its leading zero, so put quotes around anything that is really an identifier.

Fixing the most common errors

Parse errors report the line and column. Indentation must use spaces, because tabs are forbidden for it. Items at the same level must line up exactly. A colon needs a space after it to separate a key from a value, so a:b is one string. A value containing ": " or starting with a character like *, & or { needs quotes.

Duplicate keys are treated as an error, which helps, because some parsers silently keep the last one and hide the mistake.