TOML to JSON converter
Tables become nested objects and [[arrays of tables]] become arrays. Useful for feeding a pyproject.toml or Cargo.toml into a script that speaks JSON.
Conversion happens in this browser tab. Nothing is uploaded, logged, or stored.
How tables become objects
A [table] header creates a nested object, with dots in the header
creating further nesting. A [[table]] header appends to an array. Key-value
pairs attach to whichever table header last appeared above them.
title = "example"
[owner]
name = "Ada"
[[servers]]
host = "alpha"
[[servers]]
host = "beta"{
"title": "example",
"owner": { "name": "Ada" },
"servers": [
{ "host": "alpha" },
{ "host": "beta" }
]
}Type handling
| TOML | JSON |
|---|---|
"text" or 'text' | String |
42, 3.14 | Number |
true, false | Boolean |
[1, 2, 3] | Array |
1979-05-27T07:32:00Z | String — JSON has no date type |
# comment | Dropped |
Dates are the notable case. TOML has first-class datetime literals; JSON does not. They come through as ISO 8601 strings, which is the convention every JSON consumer already expects, but the type information is gone.
Supported subset
This handles the constructs that appear in real configuration files: basic and
literal strings, integers, floats, booleans, arrays, tables, dotted table headers, and
arrays of tables. Multi-line strings, inline tables, hexadecimal and octal integers, and
offset datetimes with fractional seconds are edge cases you are more likely to meet in a
spec test than in a pyproject.toml.
To write a TOML file rather than read one, use JSON to TOML. The JSON formatter will tidy the output if you plan to commit it.
For full TOML 1.0 coverage, use a dedicated library:
# Python 3.11+, standard library
import tomllib, json
with open("pyproject.toml", "rb") as f:
print(json.dumps(tomllib.load(f), indent=2))
# command line
yq -p=toml -o=json '.' Cargo.toml
Nothing is transmitted
Configuration files are read here, not collected. A TOML file typically holds database URLs, API keys, and the internal endpoints an application talks to, which is a poor thing to hand to an unfamiliar website.
You are not handing it over. Parsing happens in your browser, the JSON is built in the same tab, and closing the page is the end of it.