← All tools

YAML ⇄ JSON converter

Convert YAML to JSON and back.

How to use the YAML ⇄ JSON converter

  1. Choose a direction — YAML → JSON (the default) or JSON → YAML. Flipping the radio re-converts the current input immediately.
  2. Paste your document and click Convert. YAML becomes 2-space-indented JSON; JSON becomes clean block-style YAML with - list items and long strings folded across lines.
  3. Anchors (&), aliases (*) and merge keys (<<) are resolved during conversion, so the JSON shows the effective values your config actually produces.
  4. If parsing fails, the error names the problem plus the line and column — bad indentation and stray tab characters are the usual suspects.
  5. Click Copy to take the result.

Common uses

  • Convert a Kubernetes manifest, docker-compose file or GitHub Actions workflow to JSON for a tool or API that only speaks JSON.
  • Turn a JSON API response or schema into YAML for a config file or Helm values, formatted the way YAML files are conventionally written.
  • Expand the anchors and merge keys in a DRY config (GitLab CI, docker-compose) to see what the final, de-duplicated configuration really contains.
  • Sanity-check YAML before committing — a misplaced space fails here with an exact line and column instead of cryptically in CI.

Tips & limitations

  • Comments don't survive: JSON has no comment syntax, so # lines are dropped — round-tripping a commented config loses them permanently.
  • YAML type-guesses unquoted values: 1.10 becomes the number 1.1, and a bare date like 2024-01-15 becomes the timestamp 2024-01-15T00:00:00.000Z. Quote anything that must stay a verbatim string.
  • The classic “Norway problem” doesn't apply here — js-yaml follows the modern YAML 1.2 rules, so no, yes and on stay strings instead of turning into booleans.
  • One document per conversion: a multi-document stream separated by --- is rejected with “expected a single document” — split it and convert each part on its own.
  • Expansion is one-way: converting back to YAML won't re-create &/* references, so a de-aliased config stays fully spelled out (and correspondingly larger).

How it's built & why it's safe

Conversion runs on the open-source js-yaml v4 library (loaded from the jsDelivr CDN) plus the browser's native JSON engine. Parsing uses js-yaml's safe defaults — tags that could execute code, like !!js/function, are rejected outright. Your document itself never leaves the page: the only network request is fetching the library file, which is why an offline first visit shows “Library failed to load”. Configs full of secrets and internal hostnames stay on your machine.

Related tools: JSON Formatter · CSV ⇄ JSON Converter · Markdown Preview

Further reading: JSON vs YAML vs CSV: choosing a data format

Frequently asked questions

Why did 1.10 turn into 1.1?

Unquoted YAML scalars are type-guessed, so 1.10 parses as the number 1.1 and the trailing zero is gone. Bare dates get the same treatment and come back as full ISO timestamps. Wrap version numbers and date-like values in quotes to keep them literal strings.

Does "no" become false, like the Norway problem?

Not here. js-yaml v4 follows YAML 1.2, where only true and false count as booleans — no, yes, on and off all stay plain strings. It's older YAML 1.1 parsers that famously turn a country code like NO into false.

Are anchors, aliases and merge keys supported?

Yes — they're parsed and fully resolved, so the JSON output shows every value expanded in place. That's handy for reading a config's effective values, but the references themselves are not preserved on the way back to YAML.

Can it convert multi-document YAML files?

No — a stream with --- separators stops with an "expected a single document" error. Split the file at each --- and convert the documents one at a time.

Is my config uploaded anywhere?

No. The js-yaml library file is fetched from a CDN, but your actual text is parsed entirely in the page and never transmitted or stored — safe for configs containing API keys or internal URLs.

Why does it say the library failed to load?

The converter downloads js-yaml from a CDN the first time the page opens; if you're offline or the CDN is blocked, conversion can't start and you'll see that message. Reconnect and refresh — the conversion work itself always runs locally.