YAML to JSON Converter

Paste YAML to get formatted JSON, or paste JSON to get readable YAML. The converter understands nested maps and lists, quoted and multi-line strings, comments, inline lists like [a, b] and several documents in one file, and it points to the line where a mistake is. Use it for config files, deployment settings, API specs and data you need to move between tools.

What you enter

  • Direction
  • YAML or JSON
  • Indent

What you get

  • Status

How it works

  1. Choose YAML to JSON or JSON to YAML.
  2. Paste your text. A YAML mistake is reported with its line number, such as a duplicate key or a tab used for indentation.
  3. Pick the indent size, 2 or 4 spaces.
  4. Copy the converted result or download it as a file.

How YAML and JSON relate

JSON is strict and compact: braces, brackets, quotes and commas everywhere. YAML describes the same kinds of data with indentation instead, and allows comments, which is why it is popular for configuration files that people edit by hand. Nearly every JSON document is also valid YAML, so converting from JSON to YAML only changes how the data is written, never what it means.

The reverse is not always lossless. YAML can hold comments, anchors and several documents, and JSON cannot, so comments are dropped and a multi-document file becomes an array. The data itself, the maps, lists, strings, numbers, booleans and nulls, converts exactly.

Mistakes that change meaning without an error

The famous trap is the unquoted value that turns into something else. A country code like NO can be read as the boolean false by YAML 1.1 parsers, a version like 1.10 is a number and loses its zero, and a time like 12:30 can be read as a number of minutes. This converter follows the common YAML 1.2 rules, where only true and false are booleans, but the safest habit is to quote values that must be text.

Indentation is the second source of surprises. A key indented one space too far or too little changes the nesting without any warning from the language, and a list placed at the wrong depth belongs to a different key. When you convert to JSON, check the shape of the result: the braces and brackets make the nesting you actually wrote visible at a glance.

Tips

  • YAML uses spaces for nesting, never tabs. If you see a tab error, replace the tab characters in your editor with spaces.
  • Quote anything that must stay text. A value like 1.0 is read as a number, and a bare true or null is read as true or null, so write "1.0" or "true" in quotes to keep them as strings.
  • Numbers with a leading zero, such as the postcode 01234, are kept as text here instead of being turned into 1234 or an octal number. Quote them in your own files too, so every tool agrees.
  • A colon followed by a space ends a key. If a value contains ": ", wrap it in quotes.
  • Anchors, aliases and tags (&name, *name, !!type) are not supported. The converter says so instead of guessing, so expand them by hand first.

Frequently asked questions

How do I convert YAML to JSON?

Paste the YAML and keep YAML to JSON selected. Maps become JSON objects, dashed lists become arrays, and plain values become strings, numbers, true, false or null. For example, a line port: 8080 becomes "port": 8080.

Which YAML features are supported?

Nested maps and lists, plain, single-quoted and double-quoted strings with escapes, multi-line plain and quoted strings, block strings with | and > including the - and + options, inline lists and maps, comments, and several documents separated by ---. Anchors, aliases, tags and complex keys are reported as unsupported.

What happens with several YAML documents in one file?

If the text holds more than one document, separated by lines of ---, the JSON result is an array with one entry for each document. A single document gives a single value.

How is JSON turned into YAML?

Objects become key: value lines, arrays become dashed lists, and strings are quoted only when they have to be, for example when they look like a number, a boolean or null, are empty, or contain a colon and a space. Multi-line strings are written as block strings with |.

Is my data uploaded?

No. Parsing and conversion run in your browser, so config files containing internal names or settings stay on your device.

Related: JSON formatter, XML to JSON converter, JSON to CSV converter.

Start a 7-day free trial or see all free tools. On We.Inc you get a 7-day free trial, not a free plan: card needed, $0 today, cancel before it ends and you pay nothing. AI building is on paid plans from $20 a month.

More in Free Tools

Product

Who It's For

Features

Resources

Company

View Sitemap