Clever Quest Lab Tools

YAML to JSON Converter

2026-10-17

Convert YAML to JSON or JSON to YAML as you type. The converter reads the YAML that configuration files use – nested mappings and lists, anchors and aliases, blocks of text, comments and several documents in one file – and points to the exact line and column when something is wrong.

Convert YAML and JSON

Direction

Switching moves the current result into the input box.

Line 1, column 1

Everything is converted locally in your browser – nothing you paste is sent to a server.

How to use the YAML to JSON converter

  1. Choose the direction: YAML → JSON or JSON → YAML. If there is already a result, switching moves it into the input box, so you can convert it back.
  2. Paste or type your text into the input box, or load one of the examples. The output updates as you type.
  3. Pick the output format: 2 or 4 spaces of indentation, minified JSON on one line, keys sorted A–Z and, for YAML output, whether short lists of plain values go on one line, like [a, b].
  4. If the YAML holds several documents separated by ---, choose between one JSON array with all of them and a single document.
  5. If the input has a mistake, the output box shows the line, the column and what is wrong. Show in input puts the cursor on that spot.
  6. Copy the result, or download it as a .json or .yaml file.

How it works

The page reads YAML with its own parser, written for this tool, without any library. The parser builds a tree of mappings (key–value pairs), lists and single values, and the tree is then written out as JSON. The other direction reads JSON with its own strict parser, so mistakes get a line and column too, and writes the same tree as YAML.

The interesting part is the type of a plain, unquoted YAML value. The converter follows the YAML 1.2 core schema, the default of the current YAML specification:

Plain YAML valueBecomes in JSON
~, null, empty valuenull
true, False, TRUEtrue or false
42, -7, 0o17, 0x1F42, -7, 15, 31
1.5, .5, 6.02e231.5, 0.5, 6.02e23
.inf, .nannull with a warning (JSON has no infinity)
yes, no, on, offstrings: "yes", "no", …
2026-10-17, 1_000, 12:30strings

A value in single or double quotes is always a string, and so is a block of text. Numbers keep the digits you wrote, so 1.10 stays 1.10 and a 20-digit ID is not rounded. Only forms that JSON does not accept are rewritten: 0x1F becomes 31, 012 becomes 12, +5 becomes 5 and .5 becomes 0.5.

When writing YAML, every string is checked against the same rules in reverse. Text that would be read back as something else gets quotes: 'yes', '1.0', 'null', '2026-10-17', an empty string, text with a space at the start or end, text containing : or #, and text that starts with a character YAML reserves, such as *, &, ! or [. Words like yes, no, on and off are quoted too, so tools that still follow the older YAML 1.1 rules read them as text. Single quotes are used unless the text contains control characters; then double quotes with escapes such as \t. Text with line breaks becomes a literal block (|, |- or |+) whenever that keeps every character exact.

Examples

Example 1 – types, with JSON indentation set to 2 spaces. This YAML:

name: shop-web
replicas: 3
version: 1.10
enabled: yes
ports: [8080, 8443]

becomes:

{
  "name": "shop-web",
  "replicas": 3,
  "version": 1.10,
  "enabled": "yes",
  "ports": [
    8080,
    8443
  ]
}

The version is a number. If it is meant as text, write version: "1.10". The word yes stays a string.

Example 2 – anchors and the merge key, with Minified output:

base: &base
  image: web:2.4
  restart: always
web:
  <<: *base
  restart: never
{"base":{"image":"web:2.4","restart":"always"},"web":{"image":"web:2.4","restart":"never"}}

The alias *base copies the mapping into web, and the key written after it replaces the copied restart.

Example 3 – blocks of text, 2 spaces:

literal: |
  line 1
  line 2
folded: >-
  one
  two
{
  "literal": "line 1\nline 2\n",
  "folded": "one two"
}

| keeps the line breaks and > joins lines with spaces. The sign after it decides the end: none keeps one final line break, - removes it and + keeps all trailing ones.

Example 4 – JSON to YAML, 2 spaces:

{"answer": "yes", "version": "1.0", "empty": "", "note": "a: b", "count": 7, "tags": ["web", "api"]}
answer: 'yes'
version: '1.0'
empty: ''
note: 'a: b'
count: 7
tags:
  - web
  - api

With Short lists on one line switched on, the last three lines become tags: [web, api].

Which YAML is supported

The parser covers what configuration files use in practice:

Not supported: explicit keys written with ?, and lists or mappings used as keys (JSON keys can only be strings anyway). YAML 1.1 extras are not applied: there are no yes/no booleans, no 1:30 base-60 numbers and no date type. Duplicate keys are reported as errors, as the specification requires, and tabs are rejected in indentation.

Common YAML mistakes

Frequently asked questions

Is JSON valid YAML?

In practice, yes: YAML 1.2 was designed so that JSON documents are also YAML. You can paste JSON into the YAML → JSON direction and it converts.

What happens to comments?

JSON has no comments, so they are dropped. Converting the JSON back to YAML gives the same data, but the comments do not return.

Does the converter keep the order of keys?

Yes. Keys appear in the order of the input, including keys that look like numbers. Turn on Sort keys A–Z to sort them by character code instead, so capital letters come first.

How are several documents handled?

A YAML file with --- separators becomes one JSON array, or you can pick a single document. In the other direction, Top-level array as separate documents writes each item of the array as its own YAML document.

Why does .inf turn into null?

JSON has no value for infinity or "not a number", so these become null and a warning names the line. Quote the value if you need to keep it as text.

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser with JavaScript, and nothing you paste is sent to a server. Your last input and options are kept only in this browser's local storage, so they are still there when you come back.

Related tools