JSON to TOML Converter
Convert JSON to TOML — the config format of Cargo, pyproject.toml and Hugo — with clear errors for the two things TOML forbids.
Where TOML lives
TOML is the config format of choice for a growing corner of the tooling world: Rust's Cargo.toml, Python's pyproject.toml, Hugo, Netlify, many CLI tools. It reads like a classic INI file but has a real specification and typed values. When your data starts as JSON — generated, exported, or copied from an API — this tool rewrites it as idiomatic TOML with proper tables and arrays of tables.
The mapping
{ "package": { "name": "demo", "version": "0.1.0" },
"dependencies": { "serde": "1.0" } }
[package]
name = "demo"
version = "0.1.0"
[dependencies]
serde = "1.0" Nested objects become [table] headers, arrays of objects become [[array-of-tables]], and primitive arrays stay inline — the same shapes you know from every Cargo.toml.
Two rules TOML enforces that JSON doesn't
- No null. TOML simply has no null type. The converter tells you rather than guessing a substitute — decide yourself whether a null should become
"",0,false, or the key should be omitted. - The top level is a table. A document can't be a bare array or string — wrap it:
{ "items": [...] }.
Both cases produce a clear message instead of broken output. The reverse direction lives at TOML to JSON.
Frequently asked questions
Why does the converter complain about null values?
TOML has no null — the spec deliberately omits it. Any automatic substitution (empty string? zero? drop the key?) changes meaning, so the tool reports the problem and lets you decide. In configs, omitting the key is usually the right answer.
Why must the top level be an object?
A TOML document is by definition a table of key/value pairs — there is no syntax for a document that IS an array. Wrap your array under a key, e.g. {"servers": [...]}, and you get a valid [[servers]] array of tables.
Can I paste the output straight into Cargo.toml or pyproject.toml?
Syntactically yes — the output is spec-compliant TOML. Whether cargo or pip accepts it depends on the expected schema (section names, required fields) — that part is up to your data, not the syntax converter.
How are arrays of objects written?
As [[double-bracket]] arrays of tables — the idiomatic TOML form you see in Cargo.toml for things like [[bin]] sections. Primitive arrays like ["a", "b"] stay inline.