TOML to JSON Converter
Convert TOML to JSON and JSON to TOML online. Tables, arrays of tables, dotted keys and TOML dates are handled, with errors shown by line and column.
Convert TOML to JSON and JSON to TOML
TOML is the configuration format behind Cargo.toml, pyproject.toml, Hugo and Netlify configs. It is easy to edit by hand, but scripts, APIs and validators usually want JSON. This TOML to JSON converter shows exactly how a TOML file is structured, and converts JSON back into tidy TOML with tables and arrays of tables.
Dates, nested tables, dotted keys and integers beyond JavaScript’s safe range are handled, and syntax errors are reported with the line, column and a pointer to the problem. Conversion uses smol-toml, a TOML 1.1 parser, running entirely in your browser.
How to convert TOML to JSON
- Choose a direction: TOML → JSON or JSON → TOML.
- Paste the file contents or open a
.tomlor.jsonfile. The output updates as you type. - Fix any errors using the line and column shown, with the offending line highlighted underneath.
- Pick a JSON format (2 spaces, 4 spaces or minified), or decide whether ISO date strings should become real TOML dates.
- Copy or download the result. Swap sends the output back as input for a round trip.
TOML types and their JSON equivalents
| TOML | JSON output |
|---|---|
[server] table | "server": { … } |
[servers.alpha] | "servers": { "alpha": { … } } |
[[products]] array of tables | "products": [ { … }, { … } ] |
Dotted key backup.time = 03:30:00 | "backup": { "time": "03:30:00" } |
Inline table { cpu = 79.5 } | { "cpu": 79.5 } |
Offset date-time 1979-05-27T07:32:00-08:00 | "1979-05-27T07:32:00-08:00" |
Local date 2024-01-15 | "2024-01-15" |
Integer 0xDEAD, 1_000 | 57005, 1000 |
9223372036854775807 | Same digits, written as an exact JSON number |
inf, nan | "inf", "nan" (JSON has no equivalent) |
JSON has no date type, so all four TOML date and time kinds become strings that keep their original form, including the offset. Comments disappear because JSON cannot store them.
How JSON becomes TOML
- The top level must be an object, because a TOML document is a table. A JSON array at the top level is reported as an error.
- Nested objects become
[table]sections and arrays of objects become[[array.of.tables]]blocks. - null values are left out, since TOML has no null; the tool tells you when this happened.
- Date strings such as
"2024-03-01T09:30:00Z"become TOML date-times when the date option is on. Invalid dates such as2024-02-30stay strings. - Keys with spaces or dots are quoted, e.g.
"a.b" = 1, so they are not read as nested keys. - Whole numbers are written as integers, so a JSON
1.0becomes1.
TOML vs JSON vs YAML
| Feature | TOML | JSON | YAML |
|---|---|---|---|
| Comments | Yes (#) | No | Yes (#) |
| Date and time type | Yes, four kinds | No | Optional (YAML 1.1 timestamps) |
| null | No | Yes | Yes |
| Indentation matters | No | No | Yes |
| Typical use | App and package config | APIs, data exchange | DevOps config, CI pipelines |
Need YAML instead? Use the JSON to YAML converter.
Tips and common errors
trying to redefine an already defined table or value: the same key or[table]header appears twice.invalid valueafter=: strings need quotes in TOML, soname = Hammermust bename = "Hammer".- Keys after a
[table]header belong to that table until the next header. Put top-level keys above the first header. - Validate a
Cargo.tomlorpyproject.tomlby converting it: if JSON comes out, the TOML is valid.
Frequently Asked Questions
Common questions about converting TOML and JSON.
Paste the TOML into the converter with TOML → JSON selected. Tables become nested objects, arrays of tables become arrays of objects, and you can copy or download the JSON.
Yes. Click JSON → TOML and paste a JSON object. Nested objects become tables and arrays of objects become arrays of tables.
They become strings in their original form, for example "1979-05-27T07:32:00-08:00" or "07:32:00", because JSON has no date type.
TOML does not have a null value. Keys whose value is null are left out, and a notice tells you when that happened.
The converter uses smol-toml, which follows TOML 1.1.0 and also reads TOML 1.0 files.
Yes. Integers outside JavaScript’s safe range (above 9,007,199,254,740,991) are written to the JSON with all their digits. Programs that read the JSON as JavaScript numbers may still round them.
Common causes are missing quotes around strings, a key defined twice, or a value on a new line after =. The error shows the line and column with a pointer to the problem.
No. The parser is downloaded once from a CDN and the conversion runs locally in your browser.