navaja.dev / yaml

YAML to JSON converter (and back)

Paste YAML to get JSON, or paste JSON to get YAML. It converts both ways as you type, points at the exact line of any error, and runs entirely in your browser.

YAML indent
JSON indent

How to convert YAML to JSON

  1. Paste YAML on the left, or drop a .yaml or .yml file. The JSON appears on the right as you type.
  2. Going the other way? Paste JSON on the right and the YAML appears on the left.
  3. Fix errors fast: a syntax error names the line and column, such as a bad indent or a missing ].
  4. Copy or download the result, with JSON indented by 2 or 4 spaces, tabs, or minified.

What gets converted, and how

The Norway problem

Older YAML 1.1 parsers, such as PyYAML, Ruby's Psych and many CI tools, read unquoted NO, yes, on and off as booleans, 0755 as an octal number and 1:30 as a number of seconds. So country: NO silently becomes country: false. When converting JSON to YAML, this tool quotes every string that a YAML 1.1 reader could misread, so the YAML means the same thing everywhere.

YAML and JSON in code

Questions

Is my YAML uploaded?

No. The conversion runs in your browser with the open-source yaml library, so config files with secrets never leave your device.

What happens to comments?

JSON has no comments, so YAML comments are dropped when converting to JSON. Converting back to YAML can't restore them.

How are multiple YAML documents handled?

A file with several documents separated by --- becomes a JSON array, one element per document, which is handy for Kubernetes manifests.

Why are some strings quoted in the YAML output?

Strings like NO, yes, on, 0755 or 2026-11-07 would be read as booleans, numbers or dates by YAML 1.1 parsers such as PyYAML. Quoting them keeps them strings for every reader.

Why does my YAML give a duplicate key error?

YAML requires keys in a mapping to be unique. Two identical keys at the same level are an error rather than the last one silently winning.

What about .inf and .nan?

YAML supports infinity and NaN but JSON doesn't, so they become null in the JSON and the tool tells you which values changed.

Is YAML a superset of JSON?

Almost: YAML 1.2 accepts nearly all JSON as valid YAML. That is why you can paste JSON into a YAML file, but converting it gives cleaner block-style YAML.