· 3 min read
How to Convert YAML to JSON Without Surprises
Manesh Jayawardhana
CIO & Co-founder
YAML is pleasant to read, but it can be surprisingly opinionated when values are parsed. A version like 1.10 may become a number. A value with leading zeros can change shape. In older YAML rules, words such as NO can be interpreted as booleans, which is the classic “Norway problem.” If you convert YAML to JSON without noticing those changes, the output may be valid but wrong.
A YAML to JSON converter helps you inspect the parsed result, switch between schema rules, and catch values that may not survive conversion exactly as written.
What YAML to JSON conversion involves
YAML is a data serialization format that supports maps, lists, strings, numbers, booleans, nulls, comments, anchors, and multi-document files. JSON is stricter: it has objects, arrays, strings, numbers, booleans, and null, but no comments or YAML-specific syntax.
Conversion is not just indentation cleanup. The YAML parser decides what each value means, then the result is emitted as JSON. That parsing step is where hidden changes can happen.
Why people get stuck here
Many YAML files are written for humans, so values are left unquoted. That is convenient until a parser treats something as a number or boolean when you meant a string.
Multi-document YAML can also confuse quick converters. A file separated with --- may contain several documents, while a simple JSON output expects one root value unless the converter wraps or reports them clearly.
| YAML Input Pattern | Possible Issue |
|---|---|
version: 1.10 | May become numeric instead of a string |
id: 00123 | Leading zeros can be lost |
country: NO | YAML 1.1 may treat it as false |
Multiple --- documents | Needs clear output handling |
What a good conversion looks like
Parsed values are visible
You should be able to see what the parser understood, not just the final JSON text.
Schema choice is explicit
YAML 1.1 and YAML 1.2 differ in important ways. A converter should let you choose when that matters.
Risky reinterpretations are flagged
If YAML silently changes a value, the tool should warn you so you can quote it or revise the source.
Common mistakes to avoid
- Assuming unquoted values stay strings. YAML may infer numbers, booleans, or nulls.
- Ignoring multi-document input. More than one YAML document needs deliberate handling.
- Dropping comments without noticing. JSON cannot preserve YAML comments.
- Treating valid JSON as equivalent config. The target system may still expect YAML-specific behavior.
How to do it with YAML to JSON Converter
- Open the free YAML to JSON Converter.
- Paste your YAML into the input panel.
- Choose the YAML schema mode that matches your source.
- Review warnings for reinterpreted values, oversized integers, and dropped leading zeros.
- Copy the JSON output once the parsed structure matches what you intended.
The tool runs in your browser and uses js-yaml, so you can inspect conversion behavior without uploading config files.
Frequently asked questions
Why did my string become a number?
YAML can infer value types from unquoted text. Quote values that must remain strings.
Can YAML comments convert to JSON?
No. JSON has no comment syntax, so comments are not part of the converted data.
What is the Norway problem in YAML?
In YAML 1.1, certain words such as NO can be interpreted as booleans. YAML 1.2 reduces that surprise, but schema choice still matters.
Final thought
YAML conversion is safest when the parser’s decisions are visible. Check the warnings before trusting the JSON.