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.
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.
#) and blank lines are skipped entirely.
~ 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.
Block scalars, anchors, and aliases
| Syntax | Handling |
|---|---|
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: &name | Anchor definition. The resolved value is stored in an internal anchors table under that name as it is parsed. |
key: *name | Alias reference. Looked up directly in the anchors table and substituted in place, giving you the same JSON value at that 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.
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.
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.
From the blog
Deep dives on the things these tools touch
Minification, UUID collisions, diffing API responses, and the other questions that come up around this toolset.