JSON to TOML
Parse and convert JSON to TOML.
About JSON to TOML
Converts JSON into TOML, the configuration format used by Cargo (Rust), pyproject.toml (Python), Hugo and many CLI tools. Objects become tables, arrays of objects become arrays of tables.
When you would use it
- Writing a pyproject.toml or Cargo.toml section from data you already have as JSON.
- Translating a JSON configuration into TOML for a tool that only reads TOML.
- Learning TOML syntax by seeing how a familiar JSON structure is expressed.
How to use it
- Paste JSON (JSON5 syntax is accepted) into the left field.
- Read the TOML on the right.
- Copy the result.
Things worth knowing
- The top level must be an object. TOML has no way to represent a bare array or scalar as a whole document, so those inputs produce no output.
- Arrays mixing types (numbers and strings, for example) are written as inline arrays, which TOML 1.0 allows; older TOML parsers that still require a single type per array may reject them.
- null has no TOML equivalent; keys with a null value are omitted from the output.
- Nested objects are written as [table] and [table.sub] headers, and arrays of objects as [[array]] entries, which is the idiomatic TOML layout.
Frequently asked questions
- Why does the conversion fail on valid JSON?
- TOML is stricter than JSON: the document must be an object and null does not exist. A top-level array or scalar gives no output, and null keys silently disappear.
- Where did my key with a null value go?
- It was dropped, because TOML cannot express null. Use an empty string, a sentinel value, or simply omit the key in the consuming program.