RevealTheme logo

YAML to JSON Converter

Convert a common subset of YAML to formatted JSON entirely in your browser. This tool handles nested maps, sequences, and scalar values, but it is a lightweight parser, not a full YAML engine.

How to use this tool

  1. 1

    Paste or type your YAML into the input box, using spaces (not tabs) for indentation.

  2. 2

    Read the pretty-printed JSON that appears below the box as you type.

  3. 3

    If a red error message shows instead, check your indentation and remove unsupported syntax.

  4. 4

    Select and copy the JSON output to paste into your config, code, or API client.

How does this YAML to JSON converter actually work?

YAML and JSON are both data-serialization formats that describe the same kinds of structures: maps (key/value pairs), sequences (lists), and scalars (strings, numbers, booleans, null). JSON uses explicit braces, brackets, and quotes, while YAML relies on indentation and is friendlier to read and edit by hand. This converter walks your YAML line by line and tracks indentation with a stack to rebuild the nesting, then serializes the result with JSON.stringify and two-space indentation. Scalars are coerced by simple rules: 'true' and 'false' become booleans, 'null' and '~' become null, anything matching a plain integer or decimal becomes a number, and everything else stays a string with one layer of surrounding single or double quotes stripped. Because it is a deliberately small parser, it does NOT implement the full YAML 1.1/1.2 specification. There is no support for anchors and aliases, block or folded multi-line scalars (| and >), flow-style inline collections ({} and []), multiple documents, tags, or inline comments after a value. Only full-line comments starting with # are removed, and indentation must use spaces because tabs are not interpreted. For those edge cases, reach for a complete library such as js-yaml or PyYAML.

Common use cases

  • Quickly turning a small docker-compose.yml or GitHub Actions snippet into JSON to inspect its structure.

  • Converting a hand-written config block into JSON to paste into a tool or API that only accepts JSON.

  • Checking how YAML scalars like true, 123, or ~ get typed once they become JSON values.

  • Sanity-checking indentation in a YAML fragment by seeing whether the nesting comes out as you expect.

  • Generating seed JSON fixtures for tests from a more readable YAML draft.

  • Teaching or learning the mapping between YAML structures and their JSON equivalents.

Frequently asked questions

Which YAML features are supported?
Nested maps, sequences written with '- ', and scalar values (strings, integers, decimals, true/false, null and ~). Quotes around a scalar are stripped, and full-line # comments are ignored.
Which YAML features are NOT supported?
Anchors and aliases, block/folded multi-line scalars (| and >), flow-style inline {} and [] collections, tags, multiple documents, and inline comments placed after a value on the same line. For these, use a full parser like js-yaml or PyYAML.
Why do I need to use spaces for indentation?
The parser measures indentation by counting leading spaces only. Tabs are not interpreted as indentation, so a tab-indented file will produce wrong nesting or an error. Convert tabs to spaces first.
What happens with an inline comment like 'key: value # note'?
Only comments on their own line are removed. An inline comment after a value is treated as part of the string, so 'value # note' becomes the literal string 'value # note'. Put comments on separate lines or strip them beforehand.
Is my data uploaded anywhere?
No. The conversion runs entirely in your browser with JavaScript. Nothing you paste is sent to a server, so it is safe to use with private configuration.
Why did I get an error or unexpected output?
The most common causes are tab indentation, unsupported multi-line or flow syntax, or inconsistent spacing. Simplify the input to plain maps, lists, and scalars, or switch to a full YAML library for complex documents.

Related tools