JSON ↔ YAML Converter

Convert JSON to YAML and YAML to JSON in your browser, with formatting, error checking, and the gotchas that make YAML trickier than it looks.

The Norway problem is fixed. The version-number problem is not.

The famous complaint about YAML is that a country list starting NO: Norway parses the key as the boolean false, because YAML 1.1 treated no, yes, on and off as booleans. It is worth checking rather than repeating. This converter uses a YAML 1.2 parser, and there no is simply the string "no" — the country list comes through intact, keys and all. We test that on every build, along with no, NO, No, yes, on, off.

What has not been fixed is quieter, and for most people more likely to happen:

You writeYou getWhich is
1.0 1 (number) the trailing zero is gone
1.10 1.1 (number) version 1.10 is now version 1.1
0x10 16 (number) read as hexadecimal
012 12 (number) the leading zero is dropped
.inf Infinity (number) a real value in YAML
~ null (null) shorthand for null
true true (boolean) as you would expect

The dangerous row is 1.10. It becomes the number 1.1, and version 1.10 comes after 1.9 while version 1.1 comes well before it — so the value does not merely change, it sorts into the wrong place. Nothing warns you. The YAML is valid and 1.1 is a perfectly good number.

Converting is safe. Hand-writing is where it bites.

Here is the reassuring half. Going from JSON to YAML and back loses nothing, because the generator knows which scalars are ambiguous and quotes them. Give it {"version": "1.0"} and it writes version: '1.0', which reads back as the string it started as. Every risky value in the table above survives the round trip when a machine writes the YAML — that is checked on each build, not assumed.

The problem is a person typing version: 1.10 without quotes, in a config file nobody converted. That is where the coercion happens, and the fix is one pair of quotes: version: '1.10' comes back exactly as typed.

Worth quoting by default:

  • Version numbers — 1.10 is not 1.1
  • Country codes — NO, ON, and Y are words in some YAML versions
  • Anything with a leading zero — postcodes, phone numbers, ids
  • Dates, unless you want a Date object
  • Anything a person will read as text rather than arithmetic

The general rule underneath all of those: YAML guesses the type of every unquoted value, and it guesses well for numbers and badly for anything that merely looks like one. If a value is meant to be read as text, say so. Quotes cost two characters and remove the entire class of problem.

How to use

  1. Paste JSON or YAML into the input.
  2. The converted output appears alongside it.
  3. Check any values that could be read as booleans or numbers.
  4. Use spaces, never tabs, for YAML indentation.

Frequently asked questions

Why use YAML instead of JSON?

Comments, and readability. YAML permits comments, which JSON does not, and its indentation-based structure is less noisy for a human editing a configuration file by hand. For data exchanged between machines, JSON's strictness is an advantage rather than a limitation.

What is the Norway problem?

In YAML 1.1, the unquoted values yes, no, on, off, true and false are all booleans — so the country code NO becomes false. It has caught out a great many configuration files. YAML 1.2 restricts booleans to true and false, but many parsers still follow 1.1, so quoting anything ambiguous remains the safe habit.

Can I use tabs to indent YAML?

No. The specification forbids tab characters for indentation entirely, and a parser will reject the file. This is a common source of confusing errors when a value gets pasted in from an editor configured to insert tabs.

Why did my version number become a decimal?

Because unquoted 1.10 is a number, and numbers drop trailing zeros — so it becomes 1.1. Version strings, phone numbers, zip codes with leading zeros and anything else that merely looks numeric should be quoted.

Is every JSON document valid YAML?

Since YAML 1.2, essentially yes — the format was deliberately made a superset of JSON. The reverse does not hold: YAML has anchors, multiple documents in one file, and comments, none of which JSON can express.

What are anchors and aliases?

A way to define a block once and reuse it elsewhere in the same document, which avoids repetition in large configurations. They have no JSON equivalent, so converting YAML that uses them expands the reference into a full copy.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.