A missing two-space indent in a Kubernetes YAML file took down our staging environment for 40 minutes. The error message was cryptic. The fix was one space character. YAML's significant whitespace is its most praised and most cursed feature simultaneously. After working with all three formats across production infrastructure, here is what I actually reach for and why.
Convert YAML to JSON locally, no upload.
Parse, validate, and convert between JSON and YAML in your browser. Your config files stay on your device.
Open YAML to JSON Converter โThe Same Config in All Three Formats
Here is a database configuration expressed in JSON, YAML, and TOML. Read all three and notice what your brain finds easiest, that instinct usually points to the right answer for your use case.
1// JSON โ no comments allowed, verbose punctuation2{3 "database": {4 "host": "localhost",5 "port": 5432,6 "name": "production_db",7 "ssl": true,8 "pool": {9 "min": 2,10 "max": 10,11 "timeout": 3000012 }13 }14}1# YAML โ comments work, but whitespace is significant2# This is the production database config3database:4 host: localhost5 port: 5432 # PostgreSQL default6 name: production_db7 ssl: true8 pool:9 min: 210 max: 1011 timeout: 30000 # 30 seconds in ms1# TOML โ explicit types, comments, no significant whitespace2# Production database configuration3ย 4[database]5host = "localhost"6port = 5432 # PostgreSQL default7name = "production_db"8ssl = true9ย 10[database.pool]11min = 212max = 1013timeout = 30_000 # Underscores allowed in numbers for readabilityCapability comparison across the three formats. A checkmark means the format has that trait working in its favour.
| Feature | JSON | YAML | TOML |
|---|---|---|---|
| Comments supported | |||
| No significant whitespace | |||
| Native multi-line strings | |||
| Native date type | |||
| Browser-native parsing | |||
| Avoids implicit type coercion |
JSON: Fast, Strict, Commentless
JSON is defined byIETF RFC 8259. Its rules are intentionally minimal: six data types (string, number, boolean, null, array, object), no comments, strict quoting requirements.
The no-comments restriction is a deliberate design choice. Douglas Crockford, who formalised JSON, removed comment support because comments were being used to embed parser directives, turning a data format into a config language. For data interchange (API responses, serialised state), this strictness is a feature. For configuration files, it is a constant frustration.
Where JSON excels: speed. JSON.parse() is a native browser function compiled directly into the JavaScript engine. It is 10โ15ร faster than js-yaml and comparable to the fastest compiled-language YAML parsers.
YAML: Readable but Treacherous
YAML's design goal was human readability above all else. It achieves this, a YAML config file is often easier to read than its JSON equivalent, especially for nested structures and multi-line strings.
But YAML hides serious parsing traps.
The Norway Problem: YAML's Famous Boolean Trap
In YAML 1.1, the following strings are all parsed as boolean values without quotes:
1# YAML 1.1 boolean traps (22 values total)2true: true, True, TRUE, yes, Yes, YES, on, On, ON3false: false, False, FALSE, no, No, NO, off, Off, OFF4ย 5# Real-world consequence: country codes in a config6country_code: NO # โ parsed as false (Norway's ISO code!)7feature_flag: yes # โ parsed as true (you wanted the string "yes")8ย 9# Fix: always quote strings that might match boolean patterns10country_code: "NO"11feature_flag: "yes"YAML 1.2 fixed this, only true and false are boolean. But most parsers (including js-yaml below version 4.0, PyYAML, and Go's gopkg.in/yaml.v2) still implement YAML 1.1. Check your parser version before trusting unquoted strings.
Tabs Are Illegal in YAML
YAML prohibits tab characters for indentation. Only spaces are valid. Many code editors default to tabs for some file types, this causes silent parse failures in YAML files opened and edited by tab-defaulting editors.
1# WRONG โ tab character for indentation causes a parse error2database:3 host: localhost # โ tab here โ INVALID YAML4ย 5# Correct โ spaces only6database:7 host: localhost # โ two spaces โ validImplicit Type Coercion Surprises
YAML infers types from unquoted values. This causes data corruption in unexpected places:
1# Type coercion surprises in YAML2version: 1.0 # โ float 1.0 (not string "1.0")3phone: 07911123456 # โ int 7911123456 (leading zero stripped!)4hex_color: 0xFF # โ int 255 (hex parsed!)5date: 2026-07-02 # โ datetime object (not string!)6null_val: # โ null (empty value is null)7ย 8# These all need quoting to remain strings:9version: "1.0"10phone: "07911123456"11hex_color: "0xFF"12date: "2026-07-02"TOML: The Underrated Alternative
TOML (Tom's Obvious Minimal Language) was created by Tom Preston-Werner (GitHub co-founder) specifically to be a configuration format without YAML's ambiguity problems.
TOML's type system is explicit: strings require quotes, integers and floats are distinguished, dates are a native type, and there is no implicit coercion. A TOML file never silently converts NO to false.
It is now the default configuration format for several major ecosystems:
- Rust: Cargo.toml (every Rust project)
- Python: pyproject.toml (PEP 517/518 packaging standard)
- Hugo: config.toml (static site generator)
- Zola, Nix, uv, Rye: all default to TOML
Full Format Comparison
| Feature | JSON | YAML | TOML |
|---|---|---|---|
| Comments | No | Yes (#) | Yes (#) |
| Significant whitespace | No | Yes (indentation-based) | No |
| Implicit type coercion | No | Yes (many edge cases) | No |
| Multi-line strings | Escaped \n only | Native (| and > blocks) | Native (""" blocks) |
| Native date type | No (use ISO string) | Yes (YAML 1.1, unreliable) | Yes (RFC 3339) |
| Parse speed (Node.js) | Native (fastest) | 10โ15ร slower than JSON | 2โ5ร slower than JSON |
| Browser native support | Yes (JSON.parse) | Requires library | Requires library |
| Schema validation | JSON Schema | Limited | Limited |
Edge Cases That Break Each Format
YAML Anchors: Powerful but Confusing
YAML supports anchors and aliases for reusing values across a file. This is useful for large configs but a debugging nightmare when overused:
1# YAML anchor โ define once2defaults: &defaults3 retries: 34 timeout: 50005ย 6# YAML alias โ reuse the anchor (merges the values)7production:8 <<: *defaults # Inherits retries: 3 and timeout: 50009 host: prod.example.com10ย 11staging:12 <<: *defaults13 host: staging.example.com14 timeout: 10000 # Override just this valueAnchors work well when used sparingly. Files with anchors of anchors of anchors become very hard to debug. No equivalent exists in JSON or TOML.
JSON Trailing Commas: Still Broken in 2026
Standard JSON does not allow trailing commas. This is an endless source of parse errors:
1// INVALID JSON โ trailing comma after last element2{3 "name": "FileMint",4 "version": "2.0", // โ trailing comma โ JSON.parse() throws5}6ย 7// VALID JSON โ no trailing comma8{9 "name": "FileMint",10 "version": "2.0"11}12ย 13// Note: JSONC (JSON with Comments) and JSON5 allow trailing commas14// Use these for config files read by tools that support them (VS Code, ESLint)YAML Multi-line String Modes
YAML has two multi-line string operators with different newline handling:| (literal, preserves newlines) and> (folded, collapses newlines to spaces). Using the wrong one produces unexpected whitespace in parsed strings:
1# Literal block (|) โ preserves every newline2message: |3 Line one4 Line two5# โ "Line one6Line two7"8ย 9# Folded block (>) โ newlines become spaces (except blank lines)10message: >11 Line one12 Line two13# โ "Line one Line two14"15ย 16# Folded is for prose. Literal is for code, SQL, or anything line-sensitive.My Recommendation by Use Case
| Use Case | Format | Reason |
|---|---|---|
| REST API responses | JSON | Native browser parse, universal tooling support |
| Kubernetes / Docker configs | YAML (required) | Ecosystem standard โ no practical alternative |
| Rust, Python project config | TOML | Cargo.toml, pyproject.toml โ language ecosystem standard |
| ESLint, Prettier, TypeScript config | JSON or JSONC | Tool ecosystem uses JSON; JSONC adds comment support |
| GitHub Actions CI/CD workflows | YAML (required) | GitHub Actions format โ YAML only |
| New project config (greenfield) | TOML | Unambiguous types, comments, no whitespace traps |
When you must use YAML: always quote strings that could match boolean patterns. Set your editor to show whitespace characters. Use a YAML linter (yamllint) in your CI pipeline. These three habits eliminate the class of bugs that cost me 40 minutes in production.
For API-level format decisions (not configuration files), our XML vs JSON comparison covers the performance and schema validation tradeoffs that apply when the format is used in network communication rather than local config files. If you need to convert between formats, our YAML to JSON converter runs entirely in your browser.
Convert YAML to JSON locally.
Paste your YAML and get clean JSON. Validates syntax as you type. No upload.
Open YAML to JSON Converter โ