JSON to TOML converter — build Cargo, pyproject and Hugo configs from JSON

Paste a JSON object and get the same settings as TOML, with nested objects written as [tables], arrays of objects as [[tables]] and any null values listed, because TOML has no null.

Live demo · real result from this tool

TOML

[package]name = "toolsrift"version = "1.4.0"edition = "2021" [dependencies.serde]version = "1.0"features = [ "derive" ] [[bin]]name = "cli"path = "src/main.rs"  

Processed on your device — nothing is uploaded.

How to use the JSON to TOML converter

  1. Paste a JSON object into the Input box. The sample is a Rust package manifest in JSON form.
  2. The TOML appears straight away; there are no options.
  3. Read any yellow note about dropped null values.
  4. Copy the result or download it as config.toml.

What it does and when to use it

TOML is the config format of Rust (Cargo.toml), modern Python packaging (pyproject.toml), Hugo, Netlify and many CLI tools. If your settings live in JSON, come from an API, or are produced by a script, this converter turns them into a file those tools can read without hand-copying every key.

It is also a handy way to learn TOML: paste JSON you already understand and see how the same structure looks in table syntax.

To check the result, run it back through TOML to JSON or the TOML formatter. If your JSON has comments or trailing commas, clean it first with JSONC to JSON.

How it works

  1. The input is parsed as strict JSON. Errors show a line and column, such as Invalid JSON at line 1, column 8: unexpected “}”. for the trailing comma in {"a":1,}.
  2. The top level must be an object; anything else stops with a message.
  3. Every null, in objects and in arrays, is removed and its path is recorded.
  4. The smol-toml library, loaded in your browser, writes the TOML: simple keys first, nested objects as [parent.child] tables, arrays of objects as [[name]] blocks, and other arrays inline.

Worked examples

These are the tool’s own outputs.

The sample manifest. "package" becomes a [package] table with name, version and edition, and the nested serde dependency becomes [dependencies.serde].

Mixed values and a null. This JSON:

{"title":"App","owner":{"name":"Asha","email":null},"ports":[80,443],"ratio":2.0}

converts to:

title = "App"
ports = [ 80, 443 ]
ratio = 2

[owner]
name = "Asha"

with the note “TOML has no null, so these were left out: owner.email”.

An array of objects. {"servers":[{"name":"a","ip":"10.0.0.1"},{"name":"b","ip":"10.0.0.2"}]} gives two [[servers]] blocks, one per object.

A top-level array. [1,2] returns “TOML documents are tables, so the JSON must be an object at the top level.”

Limits and tips

  • Key order can change. Plain values are written before tables, so a nested object listed first in your JSON appears lower in the TOML.
  • Nulls inside arrays are removed too, which shortens the array.
  • No comments are added. Write explanations into the TOML afterwards.

Frequently asked questions

Why are some of my keys missing?
They had the value null. TOML has no null type, so those keys are left out, and a yellow note lists their paths, such as owner.email. Give them a real value or an empty string in the JSON if the program needs them.
Why can't I convert a JSON array?
A TOML document is always a table of keys at the top. Wrap the array in an object, for example with a key named items, and it will become [[items]] blocks.
Why did 2.0 become 2?
JSON does not tell whole-number floats apart from integers, so 2.0 is read as 2 and written as a TOML integer. If your program insists on a float, change the value to 2.0 in the TOML by hand.
Do date strings become TOML dates?
No. A JSON string such as "2024-05-01T10:00:00Z" stays a quoted TOML string. Remove the quotes in the result if you want a native TOML datetime.
Is my data uploaded?
No. The JSON is parsed and converted in your browser.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close