YAML to JSON Converter

By Cobra · Last updated

Round-trip caveats

YAML is converted with a client-side parser into JSON types: maps to objects, sequences to arrays, scalars to string/number/boolean/null. JSON back to YAML emits a readable subset. Anchors, complex tags, and custom types may not survive.

Indentation errors are the most common YAML failure. Tabs mixed with spaces often break parsers; prefer spaces only.

Worked example: a simple object with a list

YAML:

name: Ada
role: Engineer
tags:
  - seo
  - tools

JSON:

{"name":"Ada","role":"Engineer","tags":["seo","tools"]}

Limits

This is not a Kubernetes schema linter and not a full YAML 1.1 vs 1.2 compliance suite. Binary and multi-document streams need dedicated tools. Secrets in YAML still appear on screen; clear the tab when finished on a shared computer.

Numbers, booleans, and ambiguous scalars

Unquoted YAML scalars like NO, on, or 1.0 may become booleans or numbers depending on the YAML version and parser. Quote strings you want kept as text. Prefer JSON for machine interchange when type ambiguity has bitten your team before.

Worked example: the Norway problem

In YAML 1.1, country: NO is read as the boolean false, and version: 1.10 becomes the number 1.1. Quote values that must stay strings: country: "NO", version: "1.10". The JSON output then shows "NO" and "1.10" as strings. Always scan the JSON for values whose type changed.

Pitfalls

FAQ

Does YAML to JSON upload my file?

No. Parsing stays in the browser.

Why did my YAML fail to parse?

Check indentation, colon spacing, and that tabs are not mixed with spaces. Duplicate keys may also error depending on the parser.

Are anchors supported?

Basic structures are the focus. Complex anchors and custom tags may be dropped or rejected.

Can I convert JSON to YAML?

Yes. Use the direction control. Output is a readable YAML subset suitable for simple configs.

Why did my leading zeros disappear?

Unquoted values like 007 can be parsed as numbers. Quote them in the YAML so they stay strings.

Can I convert JSON back to YAML?

JSON is valid YAML 1.2, so most YAML tools accept JSON directly. For readable YAML output, use a dedicated JSON to YAML converter.