About JSON to TOML
TOML (Tom's Obvious Minimal Language) is praised for its clear, unambiguous semantics and serves as the standard config format for modern toolchains like Rust's Cargo and Python's pyproject.toml. This tool converts JSON to TOML locally in your browser, correctly turning objects into tables, arrays of objects into arrays of tables ([[table]]), and scalar values with their types intact. Two boundaries are worth knowing up front: TOML has no null type, so keys with null values are dropped, and readability declines with very deep nesting, so consider splitting configs beyond three or four levels. Key insertion order is preserved to make item-by-item comparison easy, and unsupported constructs trigger a readable notice rather than failing silently. Because conversion happens entirely on-device, nothing is uploaded — safe for configs holding secrets or environment-specific values. Handy when migrating legacy JSON configs to TOML and when rewriting API sample JSON into maintainable declarative config for review in your repository. Migrating JSON configuration to TOML usually accompanies a move from a bespoke format to an ecosystem toolchain: TOML's section headers make structure visible so a reviewer can tell at a glance which module an entry belongs to. It supports date and time as first-class types, which suits settings carrying temporal meaning. Conversion parses JSON into a tree and emits TOML: a top-level object becomes a group of key-value pairs, nested objects become headers, and arrays become either ordinary arrays or arrays of tables depending on element type. Arrays are where mistakes concentrate, since an array of objects needs double brackets while a scalar array uses single ones, and a wrong guess produces a file that will not parse. After converting, read it back with a parser rather than judging by appearance. Practical notes: Quote every field that looks numeric or boolean but is an identifier, especially version strings, identifiers with leading zeros and enumerations whose values are yes or no, or types may shift on a round trip. Then verify total key count and nesting depth, and confirm nothing was lost to same-named headers, because TOML appends to a repeated header rather than overwriting it, which is counter-intuitive and lets a conversion quietly change meaning. Limits: Comments cannot migrate from JSON, so explanatory text belongs in a field value or a separate document. JSON permits a top-level array while TOML does not, so an array-rooted configuration needs a wrapper key. Null representation differs as well, with no direct equivalent in TOML, so agree on whether to use an empty string or omit the key entirely and document that convention, or implementations in different languages will each decide for themselves. Data and privacy: such configuration usually holds connection strings and secrets. This tool converts in the browser, uploads nothing and works offline. When migrating production configuration, run the flow on a masked sample first and only then process the real file. Misuse centres on typing and structure: an identifier that looks numeric or boolean but is left unquoted gets interpreted by TOML and can change type on a round trip, and structurally JSON permits a top-level array while TOML does not, so an array-rooted configuration needs a wrapper key first. Note also that TOML appends to a repeated header rather than overwriting, the opposite of JSON intuition, which quietly changes meaning.
How It Works Internally
Conversion parses JSON into a tree and emits TOML: a top-level mapping becomes key-value pairs, nested mappings become headers, and arrays become plain or table arrays depending on element type. Note that TOML appends to a repeated header rather than overwriting, and JSON permits a top-level array only if a wrapper key is added first.
{"a":{"b":1},"list":[{"x":1}]}[a]
b = 1
[[list]]
x = 1 (nesting becomes a header, an array of objects uses double brackets)Measured on This Page
| Fixed: null became empty string | TOML has no null and the old code emitted n = "", silently turning 'missing' into 'empty string'. The key is now skipped (a = 1 stays, n disappears) |
|---|---|
| Fixed: dotted key treated as a path | {"a.b":1} now yields "a.b" = 1 rather than a.b = 1, which in TOML means key b inside table a — a different structure |
| Fixed: integer lost its last digit | 9007199254740993 comes out as the quoted "9007199254740993" instead of …992 |
| Array of objects | {"t":[{"x":1},{"x":2}]} emits two [[t]] tables in source order |
Ordering is the rule nobody mentions: every bare key/value pair of a table must precede its child tables and [[array-of-tables]] blocks, or the following 2 scalars silently join the child instead of the parent. The writer therefore emits scalars first and appends sections afterwards, and an object array becomes repeated [[items]] blocks. Parse the output back when structure matters.
How to Use
- Open "JSON to TOML"
- Paste JSON; nested objects become tables
- The TOML pane refreshes as you type
- Check table headers and array syntax
- Click the copy icon to put the TOML on the clipboard
Use Cases
- Generate Cargo config — Turn a JSON dependency list into the [dependencies] section of Cargo.toml.
- Migrate Python projects — Convert JSON-style metadata from setup.py into the TOML structure pyproject.toml needs.
- Unify config format — When a team standardizes on TOML, batch-convert legacy JSON configs.
- Understand TOML tables — Use JSON↔TOML side by side to grasp nested tables and arrays of tables.
- Toolchain integration — Convert API JSON to TOML for tools like Hugo or Netlify to read.
- Config templating — Convert a JSON template from a config generator into TOML for a project that uses pyproject.toml.
- Cross-language sharing — Export a JSON schema as TOML so a Rust and Python project share the same config structure.
FAQ
How is JSON null converted?
TOML has no null type. Keys with null values are skipped because TOML cannot represent emptiness — note these keys disappear after conversion.
What do nested object arrays become?
Arrays of objects become TOML's "array of tables" syntax [[table]], the standard way TOML expresses repeated structures.
Is deep nesting supported?
Yes, but TOML readability suffers with very deep nesting. Beyond 3-4 levels, consider splitting the config.
How are date-times handled?
Dates in JSON are usually strings and stay strings in TOML. TOML's native date types require RFC 3339 format to be recognized.
Is key order preserved?
Yes, insertion order is kept, so you can compare the original JSON and the result segment by segment to confirm nothing slipped.
Can I convert back?
Use our TOML to JSON tool for the reverse direction.
Nested arrays look different after converting to TOML?
TOML must express arrays of objects as [[array]] sections, unlike JSON nesting, so nested objects become separate sections. The structure is semantically equivalent — parsing it back yields the same data, nothing is lost.
What about keys with spaces or special characters?
TOML allows quoted keys and the tool adds them automatically; keys containing dots become nested tables, which changes the hierarchy. Quote the whole key manually to keep it flat.