JSON and YAML, side by side
Both formats describe the same kind of data: objects, lists, strings, numbers, booleans and nulls. JSON uses braces and quotes. YAML uses indentation and reads more like an outline. Config files for Kubernetes, GitHub Actions and Docker Compose lean on YAML. APIs lean on JSON.
So you end up converting back and forth all the time. This tool does it in both directions, checks the input as it goes and lets you set the indent.
Valid JSON is valid YAML
Mostly, yes. YAML 1.2 was designed so that JSON is a subset of it, and a YAML parser can read a JSON document. The reverse isn't true. YAML has comments, anchors and multiline strings that JSON simply can't hold.
What gets lost going to JSON
Comments disappear. JSON has no way to store them, so any note in your YAML is dropped when you convert. Keep the YAML as your source file if the comments matter.
Anchors and aliases are YAML's way of reusing a block. An anchor marks a chunk, and an alias points back to it. JSON has no such thing, so the tool resolves them and writes out the full repeated content. The result is longer but equal in meaning.
The 007 problem
A value like 007 can surprise you. In YAML 1.2 it can be read as a number, and as JSON it comes out as 7, with the leading zeros gone. If it's an ID or a ZIP code, wrap it in quotes in the YAML so it stays a string.
Other classic traps include the word no being read as false in some older YAML versions, and times like 12:30 turning into numbers. Quote anything that must stay text.
- Quote ZIP codes, phone numbers and version strings
- Quote the words yes, no, on and off if you mean them as text
- Check the output before committing it
Converting package.json and other config files
You can convert a package.json to YAML if a tool wants it that way. The structure carries over cleanly. Keep in mind that most tools expect package.json to stay JSON, so convert for reading or for another system and not as a replacement.
Everything runs in your browser, and nothing you paste is sent away. Config files often contain secrets, so that's a relief, but remove them anyway before sharing the output.