About the JSON to TOML
TOML was designed to be read and edited by people, which is why Rust, Python packaging and many Go projects use it for configuration. Converting from JSON means deciding how each structure is laid out: a nested object becomes a [table.header], an array of objects becomes repeated [[array.of.tables]] blocks, and simple lists stay inline on one line.
A TOML document always starts with a table, so the top level of your JSON has to be an object. If you paste an array the converter wraps it under a key you choose, which produces a valid file with your records as a block of tables instead of an error. Keys that contain spaces or punctuation are quoted so the result still parses.
The writer orders each table with its simple values first and its sub tables afterwards. That ordering is not cosmetic: in TOML every key after a table header belongs to that table, so a plain key placed after a sub table would silently land in the wrong place. Sorting keys is offered for the common case of comparing two generated configs.
A header comment is useful when the file is generated as part of a build, since it tells the next reader not to hand edit it. Check the result with the TOML Validator, and convert back with TOML to JSON.
How to use
- Paste the JSON configuration, or press Sample to load a service config.
- Set a key name if your document starts with an array rather than an object.
- Add a header comment when the file is produced by a build step.
- Download
config.toml, or copy it straight into your project.
Common questions
- Why must the top level be an object?
- A TOML file is a table of key and value pairs. An array has no keys, so it is wrapped under a name you choose to make a valid document.
- How is an array of objects written?
- As repeated [[name]] blocks, one per element. That is the TOML way of expressing a list of records.
- What happens to a null value?
- TOML has no null. Nulls are written as an empty string, so remove the keys first with the JSON Cleaner if you would rather they disappeared.
- Are dates converted to TOML datetimes?
- No. A date in JSON is just a string, so it stays a quoted string. Unquote it by hand if you want a native TOML datetime.