TOML ↔ JSON Converter
Convert TOML to JSON or JSON to TOML online. Dates become ISO strings, large integers stay exact and syntax errors show their line and column. Runs in your browser.
How to use TOML ↔ JSON
- 1Pick a mode (TOML to JSON by default), then paste TOML or JSON, or open a .toml or .json file.
- 2Set the JSON indent and whether to sort keys, or switch to Format, Validate or Tree.
- 3Copy the converted result or download it as a .json or .toml file.
What makes it better
- Mode switch: both conversions, Format, Validate and a Tree view
- Dates and times written as ISO 8601 strings
- Integers beyond 2^53 kept exactly instead of rounded
- Clear errors for null and top-level arrays when writing TOML
- A validity line shows in every mode, with line and column for errors
About TOML ↔ JSON
TOML ↔ JSON converts configuration between TOML 1.0, the format behind Cargo.toml and pyproject.toml, and JSON. Going from TOML, dates and times become ISO 8601 strings and integers too large for JavaScript are kept exactly as strings. Going to TOML, JSON that TOML cannot express, such as null values or a top-level array, is explained rather than silently altered. Format rewrites TOML in one standard layout, Validate reports the error with its line and column, and Tree browses the document, all on the same page.
Common uses
- Read a Cargo.toml or pyproject.toml as JSON so a script can inspect it.
- Turn a JSON settings file into TOML for a Rust, Python or Hugo project.
- Compare configuration kept in two formats by converting both to JSON.
- Check how a TOML array of tables looks as nested JSON.
Example
Input
title = "Example" [owner] name = "Ada" born = 1815-12-10 [database] ports = [8000, 8001] enabled = true
Result
{
"title": "Example",
"owner": {
"name": "Ada",
"born": "1815-12-10"
},
"database": {
"ports": [
8000,
8001
],
"enabled": true
}
}Good to know
- TOML has no null and its root must be a table. JSON with null values or a top-level array cannot be written as TOML, so those are reported with the path to the problem.
- A JSON string such as "1979-05-27" stays a string in TOML, because JSON cannot tell a date from text. Whole numbers like 3.0 are written as integers.
- TOML comments are not part of the data and are dropped when converting to JSON, and Format drops them too because it parses and rewrites the file. inf and nan floats cannot be written in JSON and become null, with a notice.
TOML ↔ JSON FAQ
How do I convert TOML to JSON?
Leave the direction on TOML to JSON and paste your TOML. Tables become objects, arrays of tables become arrays of objects, and the JSON appears as you type. Pick an indent or minify it, then copy or download.
Why can't my JSON be converted to TOML?
TOML requires a table at the top level and has no null. If your JSON is an array, wrap it in an object such as {"items": [...]}. If it holds null, remove that key or replace it with an empty string. The error names the exact path.
What happens to TOML dates and times?
JSON has no date type, so offset date-times, local dates and local times are written as ISO 8601 strings such as 1979-05-27T07:32:00.000Z. The notice under the result counts how many were converted.
Are very large integers preserved?
Yes. TOML allows 64-bit integers, which JavaScript numbers cannot hold exactly. Those that do not fit are written as JSON strings with their exact digits. In the other direction, big integers in your JSON are written to TOML unchanged.
Which TOML version is supported?
TOML 1.0 through the smol-toml library, including inline tables, arrays of tables, multi-line strings, hex, octal and binary integers, and all four date and time forms. Anything that is not valid TOML 1.0 is reported with its line and column.