JSON to YAML Converter: How to Convert JSON to YAML Online Free
JSON and YAML represent the same structured data in very different ways. JSON is explicit and strict — every string is quoted, every structure is delimited by braces and brackets. YAML is clean and minimal — indentation replaces delimiters, most strings need no quoting, and you can add comments anywhere.
This guide walks through how to convert between the two formats, explains the key syntax differences with concrete examples, and covers the gotchas that catch developers off guard.
Why Convert JSON to YAML?
The most common reason is human readability. YAML is significantly easier to read and write by hand, which is why it dominates in configuration files. Kubernetes manifests, GitHub Actions workflows, Docker Compose files, and Ansible playbooks almost universally use YAML. The comment support alone is a major advantage — you can document why a setting exists, which is impossible in standard JSON.
Key Syntax Differences
| Feature | JSON | YAML |
|---|---|---|
| Object delimiters | { } | Indentation |
| Array delimiters | [ ] | - prefix per item |
| String quoting | Always required | Optional for simple strings |
| Comments | Not supported | # to end of line |
| Multi-line strings | Escaped
| Block scalars: | or > |
| Null | null | null, ~, or empty |
Step-by-Step Conversion Example
JSON configuration for a web application:
{
"app": {
"name": "MyApp",
"version": "2.1.0",
"debug": false,
"port": 8080,
"database": {
"host": "localhost",
"port": 5432,
"name": "myapp_prod",
"ssl": true
},
"allowed_origins": [
"https://myapp.com",
"https://www.myapp.com"
],
"feature_flags": {
"new_dashboard": true,
"beta_api": false
}
}
}
The equivalent YAML:
# Web application configuration
app:
name: MyApp
version: "2.1.0" # Quoted to preserve as string
debug: false
port: 8080
database:
host: localhost
port: 5432
name: myapp_prod
ssl: true
allowed_origins:
- https://myapp.com
- https://www.myapp.com
feature_flags:
new_dashboard: true
beta_api: false
What changed: the outer braces are gone, most string quotes are gone, array items use - prefix, and comments are now possible.
Converting Arrays
JSON array:
{"colors": ["red", "green", "blue"]}
YAML block sequence (most readable):
colors:
- red
- green
- blue
YAML flow sequence (compact — identical to JSON syntax, valid YAML):
colors: [red, green, blue]
Converting Nested Objects
# JSON
{
"server": {
"tls": {
"enabled": true,
"cert": "/etc/ssl/cert.pem",
"key": "/etc/ssl/key.pem"
}
}
}
# YAML
server:
tls:
enabled: true
cert: /etc/ssl/cert.pem
key: /etc/ssl/key.pem
The YAML Norway Problem and Other Pitfalls
YAML 1.1 (used by many older tools including PyYAML < 6.0) automatically converts certain bare strings to booleans:
# YAML 1.1 treats these as booleans — dangerous!
country: NO # parsed as false (Norway problem)
enabled: YES # parsed as true
mode: on # parsed as true
switch: off # parsed as false
In YAML 1.2 only lowercase true and false are booleans. To be safe across parsers, always quote ambiguous values:
country: "NO"
mode: "on"
Other common pitfalls:
- Colons in values —
url: https://example.comis fine, but values with:(colon space) need quoting. - Hash signs in values —
color: "#ff0000"must be quoted; bare#starts a comment. - Leading zeros —
0755may be parsed as octal in YAML 1.1. Quote it:"0755". - Tab characters — YAML never allows tabs for indentation. Use spaces only.
Convert JSON to YAML Online — Free
IRJSON's Convert tool handles both directions with one click, entirely in your browser:
Reverse: YAML to JSON
Converting YAML back to JSON discards YAML-specific features: comments are removed, anchors and aliases are resolved and inlined, bare strings get double-quoted, and block scalars become escaped JSON strings. IRJSON handles this automatically.
When to Keep JSON vs Switch to YAML
Keep JSON when:
- The file is consumed by APIs or parsed programmatically at high frequency
- You need JSON Schema validation
- The file is generated by code, not hand-written
- Browser compatibility is required
Switch to YAML when:
- Developers edit the file frequently and comments add value
- The config is for a tool that already uses YAML (Kubernetes, GitHub Actions, etc.)
- Multi-line string values make JSON unwieldy
- You want anchors/aliases to avoid repeating config blocks
Frequently Asked Questions
Is YAML valid JSON?
No. A YAML document is not valid JSON. YAML 1.2 is designed so that any valid JSON is also valid YAML, but the reverse is not true: YAML's comments, unquoted strings, and indentation structure are all invalid in JSON.
What tools convert JSON to YAML?
IRJSON's free Convert tool works at irjson.com/convert — no sign-up, 100% in your browser. Programmatically: js-yaml in JavaScript/Node.js, PyYAML or ruamel.yaml in Python, or the yq command-line tool.
What is the YAML Norway problem?
YAML 1.1 treats bare NO (Norway's ISO 3166-1 country code) as the boolean false. The full YAML 1.1 boolean set includes: y, yes, no, n, true, false, on, off (any case). YAML 1.2 fixes this by only recognising lowercase true and false. Quote ambiguous values to be safe across parsers.
Convert JSON to YAML instantly
IRJSON handles JSON ↔ YAML in your browser — free, no sign-up, 100% private.
Open Converter →