How to use the TOML to JSON converter
- Paste TOML into the Input box. The sample is a short
Cargo.toml. - Choose the Indent: 2 spaces, 4 spaces or Compact.
- Copy the JSON, or download it as
config.json.
What it does and when to use it
Many tools read their settings from TOML, but scripts, dashboards and APIs usually want JSON. Converting lets you feed pyproject.toml metadata into a CI script, inspect a Cargo.toml with jq, or store a Hugo or Netlify config in a JSON database. It is also a good way to check how a TOML file nests: dotted headers such as [tool.ruff] are easy to misread, and the JSON makes each level explicit.
The reverse direction is JSON to TOML. To tidy a TOML file without converting it, use the TOML formatter, and for YAML configs try YAML to JSON.
How it works
The smol-toml library is loaded into your browser and parses the text under TOML 1.0 rules. It rejects anything invalid, such as a key defined twice, an unfinished string or a table header repeated. The parsed data then goes through JSON.stringify with your indent:
| TOML | JSON |
|---|---|
[table] and [a.b] headers |
nested objects |
[[name]] blocks |
an array of objects |
| inline arrays | arrays |
| hex, octal and binary integers | decimal numbers |
| dates and times | ISO 8601 strings |
inf, nan |
null |
Nothing is sent to a server.
Worked examples
These are the tool’s own outputs.
The sample Cargo.toml. The single [[bin]] block becomes an array holding one object:
"bin": [
{
"name": "cli",
"path": "src/main.rs"
}
]
A pyproject.toml with 4-space indent. [project] with a dependencies array and [tool.ruff] with line-length = 100 give a "project" object and a "tool" object that contains "ruff": { "line-length": 100 }.
Special values, compact. This TOML:
released = 1979-05-27T07:32:00-08:00
day = 1979-05-27
local = 07:32:00
hex = 0xff
inf = inf
ratio = 1.0
becomes {"released":"1979-05-27T07:32:00.000-08:00","day":"1979-05-27","local":"07:32:00.000","hex":255,"inf":null,"ratio":1}.
An unclosed string. title = 'unclosed returns “Invalid TOML document: unfinished string” with a caret at the opening quote.
Limits and tips
- Integers beyond 2^53 cannot be held exactly in JavaScript; the parser stops with an error rather than rounding them.
- Types are flattened as shown in the table, so a round trip back to TOML turns date strings into quoted strings.
- Key order is kept within each table.
Frequently asked questions
How are TOML dates converted?
Why did inf turn into null?
Does 1.0 stay a float?
Are comments carried over?
What does the error message show?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.