Example: Cargo.toml
[package]
name = "ripgrep-lite"
version = "0.2.0"
edition = "2024"
[dependencies]
regex = "1.11"
clap = { version = "4.5", features = ["derive"] }
[[bin]]
name = "rgl"
path = "src/main.rs"
[profile.release]
lto = true
opt-level = 3
{
"package": {
"name": "ripgrep-lite",
"version": "0.2.0",
"edition": "2024"
},
"dependencies": {
"regex": "1.11",
"clap": {
"version": "4.5",
"features": [
"derive"
]
}
},
"bin": [
{
"name": "rgl",
"path": "src/main.rs"
}
],
"profile": {
"release": {
"lto": true,
"opt-level": 3
}
}
}
TOML to JSON mapping
| TOML | JSON |
|---|---|
[table] | object |
[a.b.c] / dotted keys | nested objects |
[[array]] | array of objects |
{ x = 1 } inline table | object |
| string, integer, float, boolean | string, number, number, boolean |
| date-time, date, time | RFC 3339 string |
inf, nan | not representable (becomes null) |
Why convert TOML to JSON?
- Query it with jq: pipe the JSON into
jqto extract a version or list dependencies in scripts. - Debug table nesting: seeing the JSON makes it obvious which table a key actually belongs to.
- Feed other tools: many APIs, linters and dashboards accept JSON but not TOML.
# Python 3.11+ has a TOML parser built in
python -c 'import sys, tomllib, json; print(json.dumps(tomllib.load(sys.stdin.buffer), indent=2, default=str))' < Cargo.toml
# Get the package version
python -c 'import tomllib; print(tomllib.load(open("pyproject.toml","rb"))["project"]["version"])'
Need the reverse? Use JSON to TOML.
Frequently asked questions
How do I convert TOML to JSON?
Paste TOML into the tool above, or drop a Cargo.toml, pyproject.toml or any .toml file onto it. It is parsed with a fully TOML 1.0 compliant parser and shown as formatted JSON. Syntax errors show the exact line and column.
How are TOML tables and arrays of tables converted?
A [table] becomes a JSON object, and dotted headers like [profile.release] become nested objects. Each [[array.of.tables]] entry becomes an object inside a JSON array. Inline tables { a = 1 } become objects too.
How are TOML dates converted?
JSON has no date type, so TOML offset date-times, local date-times, local dates and local times become strings in RFC 3339 format, such as "1979-05-27T07:32:00.000-08:00" or "1979-05-27".
What about very large integers?
TOML integers are 64-bit. Values above 2^53 can’t be stored exactly in a JavaScript number, so this tool parses them as BigInt and writes the exact digits to the JSON output.