How to convert TOML to JSON
TOML and JSON hold the same kinds of data: tables or objects, lists, text, numbers and true or false. To convert toml to json, the tool reads your TOML with a strict TOML 1.0 parser, then writes the same data as JSON. Take this small file:
name = "app"
released = 2026-10-30
id = 9223372036854775807
ratio = 1.0
[server]
ports = [8080, 8443]With the default options it gives:
{
"name": "app",
"released": "2026-10-30",
"id": 9223372036854775807,
"ratio": 1,
"server": {
"ports": [
8080,
8443
]
}
}The status line reads Valid TOML with 6 keys, 1 table and 12 lines. Three things changed on the way, and the notes panel lists them. The date became text, because JSON has no date type. ratio lost its .0, because JSON makes no difference between 1 and 1.0. And id is flagged, which the next section explains.
Large numbers and other values JSON handles differently
TOML integers can use 64 bits, up to 9,223,372,036,854,775,807. JavaScript stores every JSON number as a 64-bit float, which is exact only up to 9,007,199,254,740,991. This tool writes every digit of a larger integer into the JSON, so the text is correct. A program that reads that JSON in JavaScript will round it, so the tool lists the path and warns you. If the number is an ID, store it as a string on the TOML side.
Floating point has two more cases. TOML allows inf and nan, and JSON cannot write them, so they become null and are listed. A TOML local time such as 07:32:00 has no date, so it is written as text without a date or zone. Offset date-times keep their offset:
{"name":"app","when":"1979-05-27T07:32:00.000-07:00","time":"07:32:00.000","local":"1979-05-27T07:32:00.000"}Comments are not kept either, because JSON has no place for them. The notes panel says so when your TOML has comment lines.
TOML validator with line and column errors
The tool doubles as a TOML validator. If a file parses, the status line begins with Valid TOML. If it does not, you get the position and a plain explanation. The Broken sample has a key with no value:
Invalid TOML at line 3, column 8: invalid value. The value after = is missing or not valid TOML. Text needs double quotes, and true, false and numbers must be spelled exactly.Some mistakes come up again and again. The same key twice in one table, or the same [table] heading twice, is reported as already defined. A string without a closing quote is reported on its line. A number such as 07 is rejected because TOML does not allow leading zeros, and an underscore in a number must sit between two digits, as in 1_000.
Convert Cargo.toml, pyproject.toml and wrangler.toml to JSON
Package and tool files are the most common reason to convert. A Cargo manifest turns into an object with package, dependencies and profile keys, and every bin entry becomes an item in a list. The Cargo and wrangler buttons load small examples you can edit.
Wrangler reads wrangler.toml as well as wrangler.json and wrangler.jsonc, and Cloudflare recommends the JSONC form for new projects. To move from TOML to JSON, convert the file here and save the result as wrangler.json. Check Cloudflare's current documentation for anything that only works in JSON files, since some newer settings are not available in TOML.
To read a TOML file in a tool that only accepts JSON, such as a script that uses jq, convert it here and paste or save the result. For the other direction, use JSON to TOML.
Options explained
- Indent: 2 spaces, 4 spaces, a tab, or minified on one line.
- Sort keys: puts the keys of every object in alphabetical order. Off keeps the order of your TOML file.
- Escape non-ASCII characters: writes characters outside plain ASCII as \uXXXX codes, for tools that expect ASCII-only JSON.
TOML to JSON in Python and on the command line
Python 3.11 and later include tomllib, so no package is needed. This reads a file and prints JSON:
import json
import tomllib
with open('Cargo.toml', 'rb') as f:
data = tomllib.load(f)
print(json.dumps(data, indent=2, default=str))The file must be opened in binary mode, and default=str writes dates as text. On the command line the same idea works as a one-liner:
python3 -c "import sys, tomllib, json; print(json.dumps(tomllib.load(sys.stdin.buffer), default=str, indent=2))" < Cargo.tomlThis page does the same job without installing anything, and shows what changed. If your config is in YAML, YAML to JSON and JSON to YAML cover that format. When a JSON value arrives as an escaped string, JSON Unescape restores it, and JSONL Viewer reads files with one JSON object per line.
Limits
- Comments are dropped, because JSON cannot hold them.
- Dates and times become ISO 8601 text with three decimals, such as 07:32:00.000. Fractions of a second beyond milliseconds are cut. The program that reads the JSON must know which fields are dates.
- inf and nan become null.
- Keys that look like whole numbers, such as 10 or 2, are moved to the front in numeric order. That comes from how JavaScript stores object keys.
- Whole numbers beyond 9,007,199,254,740,991 are written exactly but are rounded by JavaScript and many other JSON readers.
- The tool reads TOML 1.0 text. It does not check that the keys suit a particular project, such as the ones Cargo or pyproject expects.
Your TOML is converted in your browser. It is not uploaded or stored. See the Privacy Policy for details.