YAML to JSON: Convert Config Files and Catch the Norway Problem
By FindMySum · Last reviewed
This YAML to JSON converter shows exactly how a parser reads your YAML: paste a configuration file, a Kubernetes manifest or a CI pipeline and the JSON appears as you type. It runs in your browser, so secrets that often live in config files stay on your device.
Why convert YAML to JSON
YAML is easy for people to write but easy to misread: indentation carries meaning, quotes are optional, and the same plain word can be a string, a number or a boolean depending on the parser. Converting to JSON makes every type and every level of nesting explicit. It is also the quickest way to feed a YAML file to a tool that only reads JSON, such as a JSON Schema validator or a script using jq.
How to use it
- Paste your YAML. Several documents separated by
---are fine. - Leave the version on YAML 1.2 unless the program that reads the file follows the older 1.1 rules (PyYAML, Ruby's Psych and older Go libraries do).
- Keep merge keys on if the file uses
<<: *defaults, as Docker Compose files often do. - Read the warnings: each one says what JSON couldn't hold and how it was converted.
- Copy or download the JSON.
A worked example
countries: [CA, NO, SE]
debug: off
mode: 0644
With YAML 1.2 the result is {"countries": ["CA", "NO", "SE"], "debug": "off", "mode": 644}. Switch to YAML 1.1 and it becomes {"countries": ["CA", false, "SE"], "debug": false, "mode": 420}: Norway's code turned into false, off became a boolean, and 0644 was read as octal (420 in decimal), which is exactly what a file permission means. If both readings must agree, put "NO" and "off" in quotes and write the mode in a form both versions read the same way, such as the decimal 420.
Common mistakes
Tabs for indentation. YAML forbids tabs at the start of a line. Editors that insert a tab produce an error that points to the line; replace it with spaces.
Inconsistent indentation. A key indented one space less than its siblings closes the mapping early, so it ends up at the wrong level. The JSON output makes this visible.
Unquoted special characters. A value starting with @, *, &, !, % or a backtick, or containing : or #, needs quotes. Without them it becomes an alias, a tag or the start of a comment.
Duplicate keys. YAML requires keys in a mapping to be unique, but many parsers silently keep the last one. This converter reports the duplicate instead.
To go the other way, use the JSON to YAML converter; check the JSON on its own with the JSON formatter.