Why Config Format Matters
Every modern software project has configuration files: package manifests, deployment configs, CI/CD pipelines, database settings, environment definitions. The format you choose affects how easy it is for humans to edit, how likely they are to make mistakes, and how well tooling can validate and generate configs automatically.
The three formats dominating modern development are JSON, YAML, and TOML — each with distinct trade-offs. The right choice depends on who will be editing the file, how complex the data is, and what tools need to consume it.
JSON: The Universal Standard
JSON (JavaScript Object Notation) was designed by Douglas Crockford in the early 2000s as a simpler alternative to XML. Its biggest strength is ubiquity — every programming language has a JSON parser in its standard library or readily available. It is also strict and unambiguous: there is exactly one way to represent any given data structure.
{
"server": {
"port": 8080,
"host": "0.0.0.0"
},
"database": {
"url": "postgres://localhost/mydb",
"pool_size": 10
}
}
Use JSON when:
- The config will be programmatically generated or consumed by code
- You need maximum interoperability across languages and tools
- The data structure is straightforward
- You want strict parsing that rejects ambiguous or malformed input
Avoid JSON when: humans will frequently hand-edit the file. JSON has no comment support, requires quotes around all keys, and does not allow trailing commas — making it tedious to edit by hand. Consider JSONC (JSON with Comments) for config files in VS Code-based tools, or switch to TOML/YAML.
YAML: Human-Readable, But Tricky
YAML (YAML Ain't Markup Language) was designed to be as readable as possible for humans. It uses indentation to define structure — no brackets or braces — and supports comments. It is the dominant format for DevOps tooling: Kubernetes manifests, GitHub Actions workflows, Docker Compose, Ansible playbooks, and more.
# GitHub Actions workflow
name: CI Pipeline
on:
push:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: npm test
Use YAML when:
- Humans will read and write the file regularly
- You need comment support
- You are working with DevOps tooling that expects YAML
- You have multi-line strings or complex nested structures
The traps to know:
- The Norway Problem — In YAML 1.1 (still used by many tools), bare
NO,no,false,offare all parsed as booleanfalse. Country codeNOfor Norway becomesfalse. Always quote bare strings that could be misinterpreted. - Indentation errors — YAML uses spaces only (not tabs), and indentation is syntactically significant. A single misaligned line can corrupt an entire section silently.
- Implicit typing — YAML infers types aggressively.
1.0becomes a float,0644becomes an octal integer. Quote strings that look like numbers.
TOML: Explicit and Unambiguous
TOML (Tom's Obvious Minimal Language) was designed by Tom Preston-Werner (creator of GitHub) as a config format that is both human-readable and unambiguous. It uses explicit key-value pairs with clear section headers, similar to INI files but with a proper type system.
[server]
port = 8080
host = "0.0.0.0"
debug = false
[database]
url = "postgres://localhost/mydb"
pool_size = 10
timeout = 30.0 # seconds, float
[[plugin]]
name = "auth"
enabled = true
[[plugin]]
name = "metrics"
enabled = false
Use TOML when:
- You want human-readability with minimal gotchas
- Your data maps to sections and key-value pairs naturally
- You are working in the Rust ecosystem (Cargo.toml) or Python packaging (pyproject.toml)
Avoid TOML when: your data is deeply nested or highly dynamic. TOML's section-based structure gets awkward with more than 2-3 nesting levels. JSON or YAML handle complex nested data more naturally.
Quick Comparison Table
- Comments: YAML ✓ — TOML ✓ — JSON ✗ (use JSONC instead)
- Multiline strings: YAML ✓ — TOML ✓ — JSON (escaped only)
- Language support: JSON (universal) > YAML (very broad) > TOML (growing)
- Strictness / predictability: TOML > JSON > YAML
- Human editability: TOML ≈ YAML > JSON
- Schema validation tooling: JSON (JSON Schema is the standard) > YAML > TOML
Converting Between Formats
Need to migrate a project from YAML to JSON or vice versa? Use PureFormatter's YAML to JSON converter and JSON Formatter to move between formats without manual rewriting. Always validate the output after conversion — particularly when converting from YAML, since implicit type coercion may produce surprising results.