Maaz Zindani

Loading the index…

↑↓ move↵ openesc close3993 pages

Free tool · Developer tools

YAML to JSON converter

Paste YAML to get JSON, or switch direction to turn JSON into YAML. The conversion runs on your device, so configuration files with secrets are never uploaded.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

Direction
JSON
{ "name": "my-app", "version": 1.2, "ports": [ 80, 443 ], "enabled": true }
  • One YAML document
Lines
6 before, 9 after
Characters
62 before, 93 after

How to use the YAML to JSON

  1. Choose YAML to JSON or JSON to YAML under Direction.
  2. Paste your file into the box. The result appears under Result as you type.
  3. Pick the Indent: 2 spaces, 4 spaces or a tab (a tab is for JSON only; YAML never allows tabs for indentation).
  4. Press Copy or Download. If the input is wrong, a red message gives the line and column.

How do I convert YAML to JSON?

Paste the YAML and leave YAML to JSON selected. Mappings become JSON objects, lists become arrays, and scalars become strings, numbers, booleans or null. For example name: my-app with a list ports: [80, 443] becomes {"name": "my-app", "ports": [80, 443]}, indented the way you choose.

Some things in YAML have no JSON equivalent, so they change or disappear. Comments are dropped, because JSON has none. Anchors (&base) and aliases (*base) are expanded into full copies of the data. A date such as 2024-01-15 is read as a timestamp and written as "2024-01-15T00:00:00.000Z"; put it in quotes in the YAML if you want it to stay a plain string.

A file with several documents separated by ---, as in Kubernetes manifests, becomes one JSON array with one element per document. The chip under the result tells you when this happened. Anchors that expand into an enormous amount of data, a trick known as a billion laughs file, are refused with a message instead of freezing your browser.

How do I convert JSON back to YAML?

Choose JSON to YAML and paste the JSON. The output is block-style YAML with two or four spaces of indent. Switching the direction also moves the current result into the input box, so you can check a round trip in one click.

Valid JSON is nearly always valid YAML, but the tool writes the clean block form people expect in configuration files. Strings that YAML could misread are quoted: the string "yes" is written 'yes' and the key on as 'on', so that parsers which treat those words as booleans still read your data correctly. Long strings are not wrapped.

If the JSON is invalid, the message quotes the parser's own explanation, which usually points at the position of a missing comma, an extra comma at the end of a list, or single quotes where JSON needs double ones.

Why does my YAML fail, and why did "no" stay a string?

The most common errors are tabs and indentation. YAML does not allow tab characters for indentation, only spaces, and everything at the same level must line up exactly. The error message gives the line and column where the parser gave up, and the real mistake is often on the line above: a missing space after a colon, an unclosed bracket or quote, or a list item indented differently from its neighbours.

YAML has two versions in use, and they differ on plain words. Parsers that follow the older YAML 1.1 often read yes, no, on and off as true and false, and a number with a leading zero such as 010 as octal. This converter follows the YAML 1.2 core rules: yes stays the string "yes", only true and false are booleans, 010 is the number 10, and octal is written 0o17, which is 15. If a tool that you deploy to uses YAML 1.1, quote such values or use true and false so every parser agrees.

Nothing is sent over the network: the parser is code in this page, so private configuration stays on your device. Inputs over 2 MB are refused to keep the page responsive.

Use it with

Questions

How do I convert YAML to JSON?

Paste the YAML into the box with YAML to JSON selected. The JSON appears under Result and can be copied or downloaded.

Does it convert JSON to YAML too?

Yes. Choose JSON to YAML. The current result is carried into the input when you switch, so you can test a round trip.

What happens to YAML comments?

They are dropped, because JSON has no comments. Converting back will not restore them.

What happens to anchors, aliases and several documents?

Aliases are expanded into copies of the anchored data, and a file with several --- documents becomes a JSON array.

Why did yes or no become a string instead of true or false?

This tool follows the newer YAML rules where only true and false are booleans. Older YAML 1.1 parsers read yes and no as booleans, so quote them if other tools read the file.

Is my YAML uploaded?

No. It is parsed by code running in your browser, and nothing is sent anywhere.

How this page was made: the tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations were drafted with AI help and checked against the tool's own output.