Stavekit

YAML to JSON converter

Paste YAML, get formatted JSON. If something is wrong, you will see the line — and often the column — that caused the problem.

Advertisement
Advertisement

How to convert YAML to JSON

Paste your YAML into the left-hand box, or tap “Load example” to see a short, valid document. Then choose Convert. The tool reads the text in your browser and writes indented JSON on the right. You can copy the result or download it as a .json file. Nothing you paste is sent to Stavekit in order to run the conversion.

YAML is popular in configuration — Docker Compose, Kubernetes manifests, GitHub Actions, Ansible, and many application settings files — because it is easier to scan than JSON. JSON is what most programming languages and APIs expect. This page exists for that hand-off: you keep the readable source, then produce a JSON document you can paste into a tool, a test, or a request body.

What this converter does (and does not do)

The converter uses a well-known YAML parser (js-yaml, shipped with this site) and then serializes the result with standard JSON formatting, using two-space indentation. It supports ordinary mappings, lists, nested documents, numbers, booleans, and null. It is meant for a single YAML document. If you paste several documents separated by ---, check the output carefully; multi-document files are easy to misread if you only expected one object.

It will not “fix” invalid YAML for you. If a line is indented with a tab, or a quote is left open, conversion stops and an error message points to the location. That is intentional. Silently guessing can change a configuration in ways that are hard to notice later.

Common mistakes and how the error message helps

Most YAML failures come from indentation. YAML uses spaces, not tabs, to show structure. If a list item is not aligned with its siblings, or a nested key is short of the parent, the parser will complain. The message on this page includes the line number and, when the parser provides it, the column, so you can jump straight to the typo.

Quotes and special values are another frequent source of surprise. YAML 1.1 treated unquoted words such as on, off, yes and no as booleans — the well-known “Norway problem,” where a country code NO could become false. Quoting those strings is the safe habit. Colons inside unquoted values, trailing commas (which belong to JSON, not YAML), and mixing tabs with spaces will also raise errors. If JSON is what you actually pasted, use the companion JSON to YAML tool instead.

A short example

A Compose-like snippet such as a service name, a version, a list of features, and a nested map of options becomes a JSON object with the same keys and arrays. Dates and numeric-looking strings deserve a second look after conversion: a value you thought of as a string may have been parsed as a number. If you need a string, put it in quotes in the YAML before you convert.

Privacy and limits

Because the work happens on your device, you can convert fragments that you would rather not upload — tokens in a comment you forgot to remove, hostnames, or draft infrastructure. Still, treat the result with the same care as the source. Very large files may feel slow in an older phone browser; for huge documents a local command-line tool is more comfortable. This page is for everyday snippets and modest files, with a result you can trust enough to inspect.

Frequently asked questions

Is my YAML uploaded to a server?

No. The conversion runs in your browser with a local copy of the parser. We do not need your file to produce JSON.

Why do I see an error at a line number?

The YAML is invalid or ambiguous at that location. Check indentation (spaces, not tabs), quotes, and colons. The column is shown when the parser reports it.

Can I convert multiple YAML documents at once?

This tool is designed for one document at a time. Split a multi-document file on the --- markers and convert each part, then combine the JSON if you need to.

Does it change key order?

Keys are written in the order the parser provides, which typically follows the order in your YAML. It does not sort keys alphabetically.

What if I need YAML instead of JSON?

Use the JSON to YAML converter on this site. It is the same idea in the other direction, also running locally.