belun.app Blog
RU

JSON vs YAML: When to Convert and What Can Go Wrong

Where JSON and YAML each win, how the Norway problem corrupts config data, and what to check before your file round-trips between the two formats.

Code on a laptop screen — converting JSON configuration files to YAML format

JSON and YAML describe the same things: objects, arrays, strings, numbers, booleans, null. Every valid JSON document has a YAML equivalent, and almost every YAML document maps back to JSON. So why does anyone bother converting between them? Because machines prefer one and humans prefer the other — and the JSON to YAML Converter sits exactly at that boundary.

Where each format wins

JSON is what APIs speak. It’s strict, it’s fast to parse, and there’s exactly one way to write a string. That strictness is also why nobody enjoys editing it by hand: every brace has to close, every key needs quotes, and one trailing comma breaks the whole file.

YAML dropped the braces and the quote noise, and it allows comments. That last point matters more than people admit. A production config without a single # why this value comment is a config someone will break in six months. Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks — all YAML, and all meant to be read by a person during a code review.

The typical workflow: an API hands you JSON, and you need it in a Helm values file. Or the reverse — you have a docker-compose.yml and want to feed it to a script that only reads JSON. Paste, convert, done.

The Norway problem

YAML’s convenience has a price: unquoted values get interpreted. The classic case is a list of country codes:

countries:
  - DE
  - FR
  - NO

Under YAML 1.1 rules, NO parses as the boolean false. Norway vanishes from your data and nothing warns you. The same trap catches yes, on, off, and version numbers: version: 1.20 silently becomes the float 1.2 — a bug Kubernetes users hit often enough that it has its own section in the docs. Postal codes with leading zeros turn into octal numbers in older parsers.

YAML 1.2 fixed most of this (only true and false are booleans now), but plenty of parsers still default to 1.1 behavior. The safe habit: quote anything that only looks like a string. Our converter does this for you — when it turns JSON into YAML, values like "NO", "42", or "1.20" come out quoted, so they survive being read back.

What doesn’t survive the round trip

Converting YAML to JSON loses things by design:

  • Comments are gone. JSON has no syntax for them, so # don't lower this below 3 disappears.
  • Anchors and aliases get expanded or rejected. JSON can’t express “this value is a reference to that one.”
  • Key order and formatting choices (flow vs block style, quoting style) are normalized.

The data itself is safe. But if your YAML file leans on comments to explain itself, keep the original around instead of treating the JSON version as the new source of truth.

One more thing that bites people: tabs. YAML forbids them in indentation, full stop. If you assembled a file in an editor that inserts tabs, the parser stops at the first one — the converter reports the exact line, which beats staring at whitespace that all looks identical.

Validation is the quiet feature

Half the value of a converter is that it refuses bad input. Paste a Kubernetes manifest and get an error on line 14? You just found the problem before kubectl did. The JSON to YAML Converter validates both directions as you type, and everything runs in your browser — config files often contain internal hostnames and secrets, and those shouldn’t travel to someone else’s server just to get reformatted.

Paste your JSON or YAML into the converter and get the other format instantly — free, no signup, nothing uploaded.

Try the tool

JSON to YAML Converter →