JSON to TOML Converter

Paste a JSON object and get a valid TOML document with proper table headers. Nothing is sent to a server; the conversion runs in this browser tab.

JSON → TOML

Input

Settings

History

Load from URL

Why move JSON into TOML

TOML is the configuration format of the Rust and modern Python ecosystems (Cargo.toml, pyproject.toml), Hugo, Netlify and many CLIs. People convert JSON into it when:

  • A settings object generated by a script must become a hand-edited config file.
  • A project migrates from package.json-style settings or a JSON config to a tool that only reads TOML.
  • Test fixtures stored as JSON are needed as TOML samples.

TOML is stricter than JSON about structure, so the conversion is not purely cosmetic. The sections below explain what changes.

How JSON structures map to TOML

  • The top-level value must be a JSON object; it becomes the root table. A top-level array or scalar cannot be expressed in TOML and is rejected with a hint to wrap it, for example {"items": [...]}.
  • Strings, booleans and numbers become TOML strings, booleans, integers and floats.
  • A nested object becomes a [table] section; deeper nesting becomes dotted headers such as [server.tls].
  • An array of objects becomes an array of tables, one [[name]] block per element.
  • Arrays of plain values, and arrays that mix values and objects, are written inline: ports = [ 80, 443 ] or mixed = [ 1, { a = 1 } ].
  • Very large integers are written with every digit, and floats such as 1.5e300 use exponent notation.

TOML requires simple key/value pairs to come before any table header in the same table. The converter therefore writes plain values first and nested tables after them, which can reorder keys compared with your JSON. The data is the same; only the position differs.

null values are dropped

TOML has no null. Any null — as a property value or as an array element — is left out of the output, and a warning lists the paths that were removed, for example TOML has no null, so 2 null values were left out: a, list[1].

If the absence of a key would change how your application behaves, decide on an explicit replacement before converting: an empty string, false, or a sentinel your code understands.

Strings that look like dates

JSON has no date type, so a value such as "2024-03-11T10:00:00Z" is written as a quoted TOML string, not as a TOML offset date-time. The converter never guesses types from string content. If your program expects a native datetime, remove the quotes in the output for those keys.

Options, limits and tips

There are no conversion options. A few limits worth knowing:

  • TOML integers are 64-bit. Digits beyond that range are copied faithfully, but strict TOML readers may refuse them; store such IDs as strings.
  • JSON keys that are not bare-key safe (spaces, dots, non-ASCII) are quoted automatically.
  • Invalid JSON is reported with its line and column before any TOML is written.

To check the result, paste it into the TOML formatter, or convert it straight back with TOML to JSON and compare. Your data stays in the browser the whole time.

Examples

Cargo manifest from JSON

Each nested object becomes its own dotted table header, giving the layout Cargo users expect.

Input
{
  "package": { "name": "ledger", "version": "0.4.1", "edition": "2021" },
  "dependencies": {
    "serde": { "version": "1", "features": ["derive"] },
    "tokio": { "version": "1.40", "features": ["rt-multi-thread", "macros"] }
  }
}
Output
[package]
name = "ledger"
version = "0.4.1"
edition = "2021"

[dependencies.serde]
version = "1"
features = [ "derive" ]

[dependencies.tokio]
version = "1.40"
features = [ "rt-multi-thread", "macros" ]
Open this example in the tool

Array of objects and a null

The targets array becomes two [[targets]] blocks, and the null timeout is removed with a warning naming its path.

Input
{
  "title": "Build matrix",
  "timeout": null,
  "targets": [
    { "os": "linux", "arch": "x86_64" },
    { "os": "macos", "arch": "aarch64" }
  ]
}
Output
title = "Build matrix"

[[targets]]
os = "linux"
arch = "x86_64"

[[targets]]
os = "macos"
arch = "aarch64"
Open this example in the tool

Common errors and how to fix them

ErrorCauseFix
TOML needs a table (an object) at the top levelThe JSON is an array, string or number at the top level, which TOML cannot represent.Wrap it in an object, for example {“items”: […]}, and convert again.
TOML has no null, so 1 null value was left out: …A warning, not a failure: some values in the JSON were null.Replace the nulls with a real value in the JSON if the keys must exist in the TOML.
Trailing comma before ']'
Explained
The JSON input itself is invalid because of a comma after the last array item.Delete the comma or repair the input in the JSON formatter, then convert.

Frequently asked questions

Why did some keys move in the TOML output?

TOML requires plain key/value pairs to appear before table headers. Nested objects are therefore written after the simple values of the same table, regardless of their position in the JSON.

What happens to null values?

They are omitted because TOML has no null type, and a warning lists every removed path so nothing disappears silently.

Are ISO date strings turned into TOML datetimes?

No. They stay quoted strings, exactly as they were in the JSON. Unquote them by hand if your application wants a native datetime.

Can I convert a JSON array to TOML?

Not directly, because a TOML document is always a table. Put the array under a key first; an array of objects then becomes [[key]] blocks.

Related tools