How to convert JSON to YAML
Config files move between these two constantly. The conversion is mechanical, but a few YAML quirks catch people out.
Convert it
- Open the converter and go to the "Convert a file" tab.
- Add a
.json,.yamlor.ymlfile. - Choose the opposite format. JSON files offer YAML; YAML files offer JSON.
- Convert.
Worth noting for anyone handling infrastructure config: this runs entirely in your browser, so credentials, internal hostnames and environment values in a config file are not sent anywhere. Pasting a Kubernetes manifest into an online converter is a habit worth breaking.
What actually changes
Both formats describe the same thing: nested maps, lists and scalars. Converting is a re-serialisation, not a translation, so structure and values survive intact. What changes is presentation — braces and quotes become indentation.
| JSON | YAML |
|---|---|
| Braces and brackets | Indentation |
| Keys always quoted | Keys usually bare |
| No comments possible | Comments with # |
| One way to write things | Several equivalent styles |
The one genuinely lossy direction: YAML comments do not survive a round trip. JSON has no way to represent them, so converting YAML to JSON and back silently strips every comment. On a heavily documented config file this is usually unacceptable — edit the YAML directly instead.
YAML traps worth knowing
The Norway problem
In the original YAML 1.1 specification, the bare word no parses as boolean false. The country code for Norway is NO. Configuration files listing country codes have genuinely broken because of this. The same applies to yes, on, off and y. Modern parsers following YAML 1.2 treat these as strings, but plenty of software still uses older behaviour. If a value must be text, quote it.
Leading zeros and version numbers
A value like 08 may be read as a number and lose its zero, and 1.10 becomes the number 1.1, which is a problem when it was meant to be a version. Quote anything where the exact characters matter.
Tabs are illegal
YAML indentation must use spaces. A stray tab is a parse error, and an invisible one at that. If a hand-edited YAML file fails to parse, tabs are the first thing to check.
When conversion fails
Invalid YAML produces an error naming the problem rather than a half-converted file — usually inconsistent indentation, a tab, or a colon inside an unquoted string. Invalid JSON most often means a trailing comma or single quotes instead of double, neither of which JSON permits.
Related conversions
The same tab converts JSON to CSV, Excel, HTML and Markdown tables when the JSON is a flat array of records.