TOML to JSON Converter
Developer Tools · Added
Paste a TOML config and get JSON, or paste JSON and get TOML. Both directions run in this page. The parser implements TOML 1.0.0 properly — tables, arrays of tables, dotted keys, every string form, and integers in four bases — and it refuses anything it cannot read rather than quietly turning it into something plausible.
JSON
- Keys
- 15
- Tables
- 6nested objects
- Arrays
- 4
Everything runs in this page. Nothing you paste is uploaded, logged or stored, which matters here because config files are exactly where tokens and connection strings live.
How to use the toml to json converter
- 1Choose the direction: TOML to JSON, or JSON to TOML.
- 2Paste your config, or type into the box. Conversion happens as you type.
- 3For JSON to TOML, decide what to do about nulls and whether to sort keys — TOML has no null, so it is either dropped or reported.
- 4Copy the result or download it, or use Send back through to feed the output straight back in and check the round trip.
Examples
A section of pyproject.toml
- Input
- A [project] header with a name, a version and a dependencies array
- Result
- A project object holding two strings and an array of strings
Keys written after a header belong to it, so the position of a line in the file changes its meaning.
An array of tables
- Input
- [[bin]] twice, each with a name and a path
- Result
- A bin array holding two objects
Double brackets append to an array; single brackets would be a duplicate table and an error.
Something that will not parse
- Input
- port = 8080x
- Result
- Refused: 8080x is not a valid number, reported at line 1
A permissive parser would hand back the string 8080x, which looks correct and is not.
About the toml to json converter
Why TOML exists, and where it fits
TOML was designed to be an obvious configuration format — readable without a specification in hand, and unambiguous enough that two implementations agree. It sits between INI, which has no agreed grammar at all, and YAML, whose flexibility is the source of most of its surprises. It is now the standard for Rust projects through Cargo.toml and for Python packaging through pyproject.toml, which is why most people meet it for the first time when a tool tells them to edit one.
Its central idea is that a document is a table, and headers in square brackets name the sub-table that following keys belong to. Nearly everything else follows from that, including the piece that catches people out: a key/value pair written after a header belongs to that header, so the position of a line in the file changes its meaning.
Arrays of tables, the part worth understanding
Single brackets name a table; double brackets append a new element to an array of tables. Writing [[bin]] twice gives an array of two objects, whereas writing [bin] twice is a duplicate definition and an error. It is the one piece of TOML syntax that is hard to guess from context, and it is exactly what a list of build targets, dependencies or test matrices needs.
The related rule is that a header after an array of tables attaches to the most recent element. After [[fruit]] with a name, a [fruit.skin] header describes the skin of that fruit rather than of the array as a whole. That is what makes nested structures usable, and it is why the order of headers in a TOML file carries real meaning.
Converting to JSON is lossy in one direction only
JSON is the smaller language. It has objects, arrays, strings, numbers, booleans and null; TOML has all of those except null, plus four date and time types, integers in four bases, and several string forms with different escaping rules. Going from TOML to JSON therefore discards type information — a date becomes a string, a hex literal becomes a decimal number — while the values themselves survive intact.
Going the other way, the only thing JSON has that TOML lacks is null, which is why that is the one direction needing a decision from you. Everything else maps cleanly: objects become tables, arrays of objects become arrays of tables, and the rest are scalars.
Both directions run entirely in this page. That matters more than usual for this particular pair of formats, because config files are where connection strings, deployment secrets and API tokens tend to live — nothing you paste here is uploaded, logged or stored.
Frequently asked questions
What happens to TOML dates?
TOML has no null. What happens to mine?
Why does it reject things other converters accept?
Are very large integers safe?
Does the round trip give me back exactly what I started with?
Related tools
JSON to YAML Converter
Developer Tools
Convert JSON to YAML or YAML back to JSON, with the ambiguous values quoted.
ENV and INI to JSON
Developer Tools
Convert .env, .ini and .properties files to JSON, and back again.
JSON Formatter
Developer Tools
Pretty-print, minify and inspect JSON with precise error positions.
ASCII Table
Developer Tools
Searchable ASCII reference with decimal, hex, octal, binary and escapes.