One relies on indentation, one on brackets
YAML and JSON describe the same structures: key-value pairs, arrays, nested objects. JSON uses braces and brackets for hierarchy, is strict, requires double-quoted strings, and allows neither comments nor trailing commas. YAML uses indentation, permits comments and reads like a list, which makes it common in configuration. Converting either way, indentation is the trap: YAML allows spaces only, and a stray tab fails parsing outright. The tool offers both directions in one pass and lets you copy the result.
Steps
- Paste the YAML or JSON, keeping original indentation intact.
- Choose the direction: JSON to YAML, or YAML to JSON.
- Start the conversion and read any error, which usually names line and column.
- Check nesting, especially objects inside arrays, where one level often slips.
- Copy the result into the target file and run it once more.
- Reset and repeat for another document.
Indentation, types and what gets lost
YAML indentation width need not be uniform but must stay consistent within a level, and mixing two and four spaces misaligns structure. A colon needs one space after it, and values containing colons need quotes. Type inference trips people: yes, no, on and off parse as booleans in older YAML, numbers with leading zeros may read as octal, and quoting settles it. Converting YAML to JSON drops comments because the format cannot hold them, which is not a bug. Anchors and merge keys have no JSON equivalent, so expansion inflates size. Large integers lose precision past the safe range, so identifiers belong in strings.
Common mistakes
Tabs instead of spaces fail immediately. Trailing commas in JSON raise syntax errors. Unquoted colons inside values open phantom keys. Vanished comments get reported as data loss. Long numbers become scientific notation and mangle identifiers. And half-indented nesting flattens structure.
Where conversion cannot promise
Equivalence is not preserved: comments, anchors, custom tags and type markers drop, so production configs need a line-by-line diff. Secrets and credentials do not belong in online tools; local handling is safer. Multi-document YAML converts one document at a time. Circular references are invalid JSON and no tool rescues them. And overwriting live configuration without a backup and comparison is always a bad trade.