YAML to JSON converter (and JSON to YAML)

Use this YAML to JSON converter to turn YAML into JSON, and JSON back into YAML. The conversion follows YAML 1.2: nested objects, lists, multi-line text blocks, anchors with aliases and multiple documents are understood. Errors name the line, and your data never leaves the browser.

Source: YAML Language Specification, Version 1.2.2 (Syntax, Core-Schema, Skalar-Typen). Updated: .

For YAML → JSON all four options apply. For JSON → YAML, 4 spaces are used if selected, otherwise 2 spaces.
Orders the keys of every object alphabetically. Without this option the order of the input is kept.
My ToolboxYour inputs are saved in this browser only.

The text is processed in your browser only. Several YAML documents separated by --- produce a JSON list.

Your text stays in your browser – it is not sent, not stored and not added to the address bar.

Result

Result
{ "name": "My App", "version": 1.2, "active": true, "server": { "host": "localhost", "ports": [ 80, 443 ] }, "tags": [ "web", "api" ], "description": "Multi-line text\nis preserved.\n" }
Size
17 lines, 234 characters.

How it is calculated

YAML is a readable data format for configuration, used for example in Docker Compose, Kubernetes, GitHub Actions or OpenAPI. JSON is understood by nearly every programming language and API. This tool converts in both directions.

How to convert YAML to JSON

  1. Choose the direction “YAML → JSON” above.
  2. Paste your YAML or tap “Sample text”.
  3. Copy the JSON or download it as a file. “Use result as input” reverses the direction so you can check that the result converts back to the same thing.

What is supported

Nested objects and lists, values in square and curly brackets, text in single and double quotes (also across several lines), text blocks with | and > including chomping, comments, anchors with aliases and merge keys (<<), multiple documents with --- and the tags !!str, !!int, !!float, !!bool and !!null.

Types according to YAML 1.2

Limits

Complex keys (? ), custom tags and anchors on keys are not supported; you get an error message instead of a silent misreading. Comments are lost when converting to JSON because JSON has none. XML is not converted here. For JSON → YAML, numbers above 2^53 lose precision in the browser’s JSON parser, and numeric keys always come first in JSON.

Your text stays in your browser and is neither sent nor stored.

Frequently asked questions

How do I convert YAML to JSON?

Choose the direction “YAML → JSON” and paste the YAML. The JSON appears immediately and you can copy or download it. If something is wrong, the message names the line.

Why does “yes” not become true?

Because this tool uses YAML 1.2. There only true and false are booleans; yes, no, on and off stay text. YAML 1.1 treated them as booleans, which often caused bugs (the “NO” for Norway problem).

Are comments lost?

Yes, when converting to JSON, since JSON has no comments. In the other direction the YAML has no comments because the JSON contains none.

What happens with several documents in one file?

Documents separated by --- are combined into one JSON list, one entry per document. A single document stays as it is.

How are anchors and aliases handled?

An alias is replaced by the value of its anchor. The merge key “<<” inserts the keys of an anchor; existing keys take precedence. Extremely branching aliases are rejected as abuse.

Is my input uploaded?

No. The conversion runs in your browser; the text is not sent, not stored and not written to the address bar.

Sources and legal basis

As of:

Related tools