YML

YAML JSON Converter config

Convert YAML configuration to JSON and JSON back to YAML, with adjustable indentation.

direction
indent
INPUTyaml
0 lines 0 chars
1
OUTPUTjson
0 lines 0 chars
1
Tool Guide

What this tool does

YAML expresses structure through indentation. With few brackets and quotes it is comfortable to read and write, which is why it became the default for Docker Compose files, Kubernetes manifests, GitHub Actions workflows, and application configuration generally.

Programs, on the other hand, usually work with JSON. Request bodies, browser console inspection, and schema validation tools are built around it. Converting a YAML file to JSON is therefore the fastest way to see how its structure is actually being interpreted.

This tool runs the js-yaml library in your browser to convert in both directions. It handles nested maps and sequences, multi-line strings, and ordinary documents without anchors. A successful conversion also confirms the syntax is valid, which makes it useful for catching configuration errors.

When to use it

Use it to confirm that indentation in a Kubernetes manifest or Actions workflow produces the structure you intended, to move YAML configuration into a JSON request body, to catch syntax errors before deploying a config file, or to migrate JSON configuration to YAML.

Input and output examples

Input name: alice roles: - admin - dev active: true
Output {"name":"alice","roles":["admin","dev"],"active":true}

Lines beginning with a hyphen become array entries, and true is read as a boolean.

Input version: 1.10
Output {"version":1.1}

Without quotes this is read as a number and the trailing zero disappears. Write "1.10" to keep it a string.

Notes and limitations

Indentation causes most YAML accidents. Tab characters are not permitted, so use spaces, and a single space of difference reparents an entry. Watch the implicit typing of unquoted scalars too: yes, no, on, off, true, and false become booleans, values such as 08 may be read unexpectedly, and the notorious case of the country code NO becoming false is well documented. Quote anything that must remain a string, such as version numbers and country codes. If the converted output shows the wrong type, add quotes in the source.

Frequently asked questions

Why does tab indentation fail?

The YAML specification forbids tab characters for indentation. Use spaces, and configure your editor to insert spaces instead of tabs.

I wrote no and it became false.

YAML 1.1 style parsing treats yes, no, on, and off as booleans. Quote the value as "no" to keep it a string.

What happens to comments?

JSON has no comments, so anything after # is lost when converting to JSON. The conversion is not reversible, so keep the original.

Copied