How to convert TOML to JSON
By Flavio
Convert a TOML document to JSON in the browser, then turn that JSON back into TOML. Dates become strings. NaN and Infinity become null.
Free toolThis tutorial uses the TOML to JSON Converter. It runs in your browser, so open it in another tab and follow along.
TOML is a config file. JSON is what most programs pass around. The TOML to JSON converter does both directions in the browser. The document stays on the page. It is not stored in the URL.
The parser is smol-toml 1.9.1, checked on November 4, 2026. JSON is indented by two spaces. TOML is written in the shape that library emits, with a trailing newline.
Convert the sample
- Open the TOML to JSON converter.
- Leave the direction on TOML to JSON.
- Click Load sample.
- Copy writes the JSON. Download saves
document.json.
The sample is:
name = "Flavio"
n = 1
tags = [ "toml", "json" ]
[owner]
site = "https://flaviocopes.com"
[[servers]]
host = "a"
[[servers]]
host = "b"
The JSON is:
{
"name": "Flavio",
"n": 1,
"tags": [
"toml",
"json"
],
"owner": {
"site": "https://flaviocopes.com"
},
"servers": [
{
"host": "a"
},
{
"host": "b"
}
]
}
Switch the direction to JSON to TOML and paste that JSON back. The TOML matches the sample, including the trailing newline. Download then saves document.toml.
A hex integer becomes a number. 0x10 is 16. An integer JavaScript cannot store exactly is an error. big = 9007199254740993 reports Line 1, column 7: integer value cannot be represented losslessly. The page does not turn that into a bigint.
Dates, NaN, and null
Click Load dates for the other mapping. The TOML is:
offset = 1979-05-27T07:32:00Z
shifted = 1979-05-27T07:32:00-07:00
local = 1979-05-27T07:32:00
day = 1979-05-27
clock = 07:32:00
nan = nan
inf = inf
ninf = -inf
hex = 0x10
The JSON is:
{
"offset": "1979-05-27T07:32:00.000Z",
"shifted": "1979-05-27T07:32:00.000-07:00",
"local": "1979-05-27T07:32:00.000",
"day": "1979-05-27",
"clock": "07:32:00.000",
"nan": null,
"inf": null,
"ninf": null,
"hex": 16
}
The notes are:
offset is a TOML date. JSON gets “1979-05-27T07:32:00.000Z”.
shifted is a TOML date. JSON gets “1979-05-27T07:32:00.000-07:00”.
local is a TOML date. JSON gets “1979-05-27T07:32:00.000”.
day is a TOML date. JSON gets “1979-05-27”.
clock is a TOML date. JSON gets “07:32:00.000”.
nan is NaN. JSON has no NaN, so this value is null.
inf is Infinity. JSON has no Infinity, so this value is null.
ninf is -Infinity. JSON has no -Infinity, so this value is null.
A date becomes the string from toJSON. Milliseconds are written even when the TOML omitted them. A local datetime has no Z. A local time is only the clock.
The way back rejects null. This JSON fails:
{ "a": { "b": null } }
The error is: a.b is null. TOML has no null.
smol-toml would drop that key. The page stops instead. A JSON array also fails, because a TOML document is a table. The error is: A TOML document is a table. The JSON root has to be an object.
Files up to 1 MB open from Open file. The page stops at 1,000,000 characters.
How to start a blog using Hugo uses a config.toml. Run an app on fly.io uses a fly.toml. What happens when Bun runs a TypeScript file reads bunfig.toml before the program starts.
YAML to JSON is the same job for YAML. JSON formatter pretty-prints the result. XML to JSON covers the XML mapping.
Try the TOML to JSON Converter
Convert TOML to JSON and JSON back to TOML in the browser. Dates become strings, NaN and Infinity become null, and a null value is rejected on the way back.
Open the TOML to JSON Converter →
Related tools
- YAML ↔ JSON Converter: Convert YAML to JSON and back with indent options, line-number errors, and warnings for classic YAML gotchas.
- JSON Formatter & Validator: Validate, pretty-print, and minify JSON with clear error messages. Runs entirely in your browser.
- XML to JSON Converter: Convert XML to JSON and JSON back to XML in your browser. Attributes, repeated elements, and text follow one documented mapping.
Want me to talk about your product? You can sponsor this site.