Convert TOML to JSON without surprises
TOML is pleasant to write, but many programs, dashboards and APIs expect JSON. This TOML to JSON converter parses your file with a TOML 1.0 parser and emits the equivalent JSON, so you can feed a pyproject.toml into a script, compare two Cargo.toml files as data, or store configuration in a database column that expects JSON.
Example
# Project manifest
title = "inventory-service"
released = 2024-05-14
[database]
ports = [5432, 5433]
enabled = true
[[servers]]
name = "alpha"
role = "primary"
Converted with a 2-space indent:
{
"title": "inventory-service",
"released": "2024-05-14",
"database": {
"ports": [
5432,
5433
],
"enabled": true
},
"servers": [
{
"name": "alpha",
"role": "primary"
}
]
}
How TOML maps to JSON
| TOML | JSON |
|---|---|
[table] and dotted keys a.b = 1 | nested objects |
[[array.of.tables]] | array of objects |
inline table { x = 1 } | object |
integer (incl. 1_000, 0x1F) | number |
date 2024-05-14 | string "2024-05-14" |
| offset date-time | ISO 8601 string, e.g. "1979-05-27T07:32:00.000-08:00" |
inf, nan | null (JSON has no equivalent) |
Comments are dropped, since they are not part of the data. Key order follows the file unless you tick Sort keys, which sorts keys alphabetically at every level. The Indent option (2, 3 or 4 spaces or a tab) only affects how the JSON is laid out, not its content.
Edge cases
- Big integers. TOML supports 64-bit integers, but JavaScript cannot hold values above 253 − 1 exactly, so such values are rejected with a clear error instead of being rounded.
- Dates are strings in JSON. If your program needs real date objects, parse the strings after loading the JSON.
- Nested arrays of tables are attached to the most recent parent element. A
[[servers.ports]]header after[[servers]]adds a port to the last server, giving{"servers":[{"name":"a","ports":[{"n":80},{"n":443}]}]}. - Invalid TOML is reported with line and column, for example a key defined twice or an unquoted string value.
Typical uses
- Reading project metadata in scripts. Convert
pyproject.tomlorCargo.tomlto JSON and query it with tools that understand JSON, such asjq, or the JSONPath tester. - Sending configuration to an API. Many deployment and CMS APIs accept settings as JSON while the source of truth lives in a TOML file.
- Comparing environments. Two TOML files with different layouts can hold the same data. Converting both to JSON with Sort keys ticked makes them directly comparable.
- Checking structure. The JSON makes it obvious whether a key landed in the table you intended, which is easy to get wrong with dotted keys and arrays of tables.
Most languages ship with a JSON parser in the standard library, while TOML support often needs an extra package. Converting once can remove that dependency from a small script or a build step.
Round trips and related conversions
Need to go back? The JSON to TOML converter writes TOML from JSON, though comments and original formatting cannot be recovered. To inspect the file without converting it, the TOML validator shows the same structure, and the JSON to YAML converter can take the result on to YAML.
Privacy
The conversion runs in your browser; your configuration is not uploaded. Our server is involved only if you use Load URL or Save & Share.