Three formats, three personalities
Most software is configured through a text file, and three formats dominate. They hold the same kind of data, which is named values, lists and nested groups, but they feel very different to write.
| Format | Strengths | Weak points |
|---|---|---|
| JSON | Strict, universal, easy for programs to read and write | No comments, quotes on every key, trailing commas not allowed |
| YAML | Very readable, comments, compact lists | Indentation matters, and some plain values are read as numbers or booleans |
| TOML | Clear sections, comments, simple rules, popular for project settings | Deeply nested data becomes long and repetitive |
A good rule of thumb: use JSON when programs exchange data, YAML for human-edited files with lots of nesting such as pipelines and orchestration, and TOML for settings with a few sections.
The same data in each format
Here is one small configuration written three ways.
With the YAML to JSON Converter you paste either format and the tool works out the direction itself. Text that begins with a curly brace or square bracket is read as JSON and written as YAML, and anything else is read as YAML and written as JSON. The TOML to JSON Converter works the same way for TOML.
The classic YAML traps
YAML guesses the type of plain values, which is convenient until it guesses wrong.
- Numbers that are really text. A value such as 123 is a number, but a postcode or an ID that must keep its form should be quoted as "123".
- Booleans. true and false are booleans. Some YAML versions also read words such as yes and no this way, which has bitten country codes (NO for Norway).
- Colons. A string that contains a colon followed by a space, like "x: y", must be quoted or it is read as a nested key.
- Empty values. A key with nothing after it is null, not an empty string.
- Indentation. Use spaces, never tabs, and keep the same step throughout a block.
When the converter writes YAML, it quotes strings that could be misread, including numbers, true and false, text with a colon and space, and empty text. It writes empty lists and maps as [] and {}.
What the converters support and what they do not
The converters on ProIT are lightweight tools for ordinary configuration files. Be clear about the limits before you rely on them.
- Supported in YAML: nested maps, lists, quoted and plain strings, numbers, true, false, null, empty [] and {}, simple inline lists and maps, and trailing comments.
- Not supported in YAML: anchors and aliases (&name and *name), multi-line block text written with | or >, tags, and several documents in one file. Handle these by hand or with a full YAML library.
- Comments are lost. JSON cannot store them, so converting YAML or TOML to JSON drops every comment.
- TOML: common keys, tables and arrays are handled. Test unusual constructs before using the result.
Both tools process the text on ProIT’s server for the request, so do not paste secrets such as API keys or passwords.
A checklist before and after converting
- Back up the original file.
- Remove anchors, aliases and multi-line blocks, or plan to rebuild them.
- Note any comments you want to keep and copy them somewhere, since they will not survive a conversion to JSON.
- Convert, then compare the result with your original expectations. The File Diff Checker can compare two versions: paste the first, a line containing only three dashes, and then the second. It aligns matching lines first, so one inserted line does not mark everything after it as changed.
- If the JSON will be validated, create a starting schema with the JSON Schema Generator. It marks every key in your sample as required, so remove optional keys from the list.
- Load the converted file in the real application or a test environment before using it for real.
Choosing a format for a new project
If you are starting a project and have a choice, ask three questions. Who edits the file: people, programs or both? How deeply nested is the data? Does your tool already expect a format? Following the format your framework or deployment tool uses is almost always the right call, because examples, editor support and error messages will all match it.
For files that people review in pull requests, readability and comments count for more than strictness, which favours YAML or TOML. For data that moves between services, JSON’s strict rules make mistakes easier to catch. Whichever you pick, keep one format per purpose and convert only when you must, because every conversion is a chance to lose a comment or change a type.
After converting a file you plan to keep, read it through once and run it in a test setting. A conversion that looks right can still change meaning, such as a quoted number turning into a plain one.