YAML to JSON

Convert YAML to JSON or JSON to YAML, with the common subset handled and the limits stated.

10Input lines
14Output lines
120Input characters
yesParsed

Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.

What the YAML to JSON does

The YAML to JSON on this page will convert YAML to JSON or JSON to YAML, with the common subset handled and the limits stated. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for converting a configuration file between the two formats. If you want to cross-check the result, there is another YAML to JSON on FreeToolsWorld.org.

How to use it

  1. Paste your YAML.
  2. Read the JSON on the right.
  3. Tick the reverse option to convert JSON into YAML instead.
  4. Check the parsed indicator — it tells you whether the input was understood.

How it works

The YAML reader here handles the subset people actually write in configuration files: mappings, sequences, nesting by indentation, quoted and unquoted scalars, the usual type inference for numbers and booleans, inline comments, and block scalars — both the literal | and the folded >, with their chomping indicators. Block scalars matter more than their obscure syntax suggests, because any embedded script, certificate or multi-line message is written as one. It does not implement anchors and aliases, multi-document streams or flow collections, and the honest reason to state that is that a parser which silently mangles an anchor is worse than one that refuses it.

YAML's type inference is the source of its most famous problem and it is worth knowing before you rely on a conversion. Unquoted `yes`, `no`, `on` and `off` have historically been read as booleans, which is why the Norway country code `NO` has become the standard example of a configuration file breaking in an unexpected way. Version numbers suffer similarly: unquoted `1.10` is the number 1.1, not the string. Quote anything that must stay a string.

Converting in the other direction, JSON to YAML, quotes any string that YAML would otherwise read as another type — so a value of `true` or `1.10` comes back quoted rather than silently becoming a boolean or a number. That round trip is the one that matters for configuration files, since a converter that loses the distinction produces a file that loads differently from the original.

Indentation in YAML is significant and tabs are forbidden outright — a tab character where YAML expects spaces is a parse error in every conformant implementation. If a YAML file that looks correct refuses to parse, an invisible tab is the first thing to check.

When to use it

  • Converting a configuration file between the two formats.
  • Reading a YAML file as JSON to check its structure.
  • Producing YAML from a JSON API response.
  • Checking whether a YAML file parses the way you expect.

Common mistakes to avoid

  • Leaving version numbers and country codes unquoted. 1.10 becomes 1.1 and NO becomes false.
  • Using tabs for indentation. YAML forbids them and the error is often unhelpful.
  • Expecting anchors and aliases to survive. This converter does not implement them.

Frequently asked questions

What YAML features are not supported?

Anchors and aliases, multi-document streams, and flow collections. Everything else commonly used in a configuration file is handled: mappings, sequences, nesting, scalars, comments, and block scalars in both the literal (|) and folded (>) styles with their chomping indicators.

Why did my value change type?

YAML infers types from unquoted scalars. `yes`, `no`, `true` and `false` become booleans, and `1.10` becomes the number 1.1. Quote anything that must stay a string — this is the cause of the well-known Norway problem, where the country code NO is read as false.

Why will my YAML not parse?

Most often an invisible tab character. YAML forbids tabs for indentation, and editors that insert them produce files that look correct and refuse to load.

Related tools

See all developer tools →