YAML to JSON Converter Online Free

💻 Developer Tools ✔ Free Forever

YAML to JSON Converter Online Free

Convert YAML to clean, valid JSON instantly. Handles anchors, aliases, multi-document files, nested mappings, and Kubernetes configs. Everything runs in your browser.

✔ Anchors and aliases ✔ Multi-document YAML ✔ Kubernetes configs ✔ JSON to YAML reverse ✔ 100% browser-based
JSON Indent
Input YAML
Parse error
Output JSON
Choose a sample
About This Tool

A hand-written YAML parser covering the subset you actually hit in config files

There is no js-yaml or other library loaded here. This tool parses YAML with a recursive, indentation driven function written specifically for this converter, built to handle the constructs that show up constantly in Kubernetes manifests, Docker Compose files, and CI configs: nested mappings, sequences, block scalars, and anchor/alias references. It is not a full YAML 1.1 or 1.2 implementation, and knowing where that line sits matters if you are pasting something unusual. Conversion runs entirely client side.

How indentation drives the recursive parse

YAML’s structure is defined by leading whitespace rather than brackets, so the parser’s central function, parseBlock, takes a starting line index and a base indentation level, then reads forward. Any line indented less than the base level means the current block has ended and control returns to the caller. Any line at exactly the base level is either a sequence item (starts with a hyphen and a space) or a mapping key (contains a colon), and a line indented deeper than the base level triggers a recursive call to parse a nested block.

Step 1 Measure indentation A small helper counts leading space characters on each line. This number is compared against the current block’s base indent to decide whether a line belongs to this block, starts a nested block, or ends the current one.
Step 2 Classify the line A line starting with a hyphen and a space is a sequence item. A line with a colon at top level is a mapping key. Comments (lines starting with #) and blank lines are skipped entirely.
Step 3 Recurse on deeper indentation When a key’s value is empty on the same line, meaning the actual value sits on following lines indented further in, the parser calls itself with that deeper indent level as the new base.
Step 4 Coerce scalar types Plain scalar values are checked against YAML’s type conventions in order: empty or ~ becomes null, true/yes/on and false/no/off become booleans, numeric strings (including 0x hex and 0o octal) become numbers, and quoted strings have their escape sequences resolved.
// scalar type coercion, in the order the parser checks it function parseValue(val) { var t = val.trim(); if (t === || t === ‘null’ || t === ‘~’) { return null; } if (t === ‘true’ || t === ‘yes’ || t === ‘on’) { return true; } if (t === ‘false’ || t === ‘no’ || t === ‘off’) { return false; } if (!isNaN(Number(t)) && t !== ) { return Number(t); } return t; // falls through to plain string }

Block scalars, anchors, and aliases

SyntaxHandling
key: |Literal block scalar. Every following line at deeper indent is kept as-is, newlines preserved, common in multi-line shell scripts inside CI YAML.
key: >Folded block scalar. Following lines are joined with spaces instead of newlines, producing one flowed paragraph.
key: &nameAnchor definition. The resolved value is stored in an internal anchors table under that name as it is parsed.
key: *nameAlias reference. Looked up directly in the anchors table and substituted in place, giving you the same JSON value at that key.
The merge key <<: *name is not specially handled. Standard YAML treats << as a merge key that splices an anchored mapping’s keys directly into the current mapping. This parser treats it as a literal key named << whose value is the resolved anchor, so you will get a "<<" property in your JSON output containing the referenced object, rather than having those keys flattened into the parent. If your config relies on YAML merge keys, expect that specific difference and adjust the output by hand.

Multi-document support and the reverse direction

Multi-document YAML

Input is first split on lines containing exactly ---, the YAML document separator. A single document returns one JSON value; multiple documents are parsed independently and returned as a JSON array.

JSON back to YAML

The reverse converter walks a JSON value recursively, quoting strings that contain YAML-significant characters like colons or brackets, and switching multi-line strings to the literal block style automatically.

Indentation-driven recursive parser Anchors and aliases Literal and folded block scalars Multi-document (—) support

YAML specifications and parsers

  • YAML 1.2.2 Specification is the full formal grammar this tool implements a practical subset of.
  • js-yaml is the standard JavaScript library for complete, spec-compliant YAML parsing including full merge key support, worth reaching for if you hit a construct this tool does not cover.
  • Kubernetes configuration overview is a good reference for the anchor and multi-document patterns this parser was built to handle.
  • YAML merge key type specification documents the << behavior this tool does not implement, for anyone who needs it.

Config work this handles

Converting a Kubernetes manifest or Docker Compose file into JSON to feed into a script that expects JSON input, checking exactly how a CI pipeline’s YAML config will be parsed before debugging a failed build, translating application config between YAML and JSON formats depending on what a given tool accepts, and inspecting anchor and alias references in a config file to see the fully resolved values they expand to.

Common Questions

FAQ: YAML to JSON Converter Online Free

Yes, completely free. No account, no trial, and no payment required at any point.

No. All conversion runs in your browser using JavaScript. Your config files and secrets never leave your device.

Yes. Anchors defined with the ampersand syntax and aliases referenced with the asterisk syntax are resolved correctly in the JSON output. This is especially useful for Kubernetes and Docker Compose files that use default blocks.

Yes. Kubernetes manifests are standard YAML and work directly. Try the Kubernetes Pod sample to see how a typical manifest looks after conversion.

Multi-document YAML files separated by the triple dash separator are converted into a JSON array, with each document becoming one item in the array.

Yes. Click the JSON to YAML button to reverse the mode. Paste your JSON into the input and the tool generates clean, properly indented YAML output.

Check that the Parse numbers option is enabled in the options row. When enabled, values like 42 or 3.14 become JSON numbers. When disabled, all scalar values remain as strings.

Privacy Overview

Cookies let this site remember your preferences and show us which tools people actually use. Full detail sits in our Privacy Policy.