JSON to YAML Tutorial: Convert JSON to Readable Config
JSON and YAML can represent the same basic data types: strings, numbers, booleans, null, arrays, and objects. YAML removes many braces and quotes, which makes config files easier to scan when indentation is correct.
Convert a JSON object to YAML
{
"server": {
"host": "localhost",
"port": 8080,
"debug": true
}
}server:
host: localhost
port: 8080
debug: trueConvert JSON arrays to YAML lists
JSON arrays become YAML sequences. Arrays of objects become repeated list items with nested fields.
{
"plugins": [
{ "name": "auth", "enabled": true },
{ "name": "billing", "enabled": false }
]
}plugins:
- name: auth
enabled: true
- name: billing
enabled: falsePreserve JSON types
JSON values should map to the equivalent YAML type. Strings that look like booleans, numbers, or dates should be quoted if you want them to remain strings.
{
"enabled": true,
"retries": 3,
"version": "1.0",
"zip": "00123",
"deletedAt": null
}enabled: true
retries: 3
version: "1.0"
zip: "00123"
deletedAt: ~Watch YAML indentation
YAML structure depends on indentation. Use spaces, not tabs, and keep nesting consistent.
# Good
database:
host: localhost
pool:
min: 2
max: 10
# Bad: inconsistent indentation changes structure or fails parsing
database:
host: localhost
pool:
min: 2Common JSON to YAML mistakes
- Forgetting to quote strings that look like numbers, dates, or booleans.
- Mixing tabs and spaces.
- Changing nested structure while hand-editing indentation.
- Assuming comments from YAML can be converted back to JSON.
- Using YAML features that the target tool does not support.
Convert JSON to YAML online
Paste JSON into Jsonic's JSON to YAML converter to produce readable YAML locally in your browser.
Open JSON to YAML