Paste JSON and get valid TOML with tables and arrays of tables as you type.
Paste JSON, upload a .json file or drop one here.
Updates as you type. Copy it or download config.toml.
Converting…
This free JSON to TOML converter turns a JSON document into valid TOML 1.0. Paste an API response, an exported config or settings you have kept as JSON, and the TOML version appears as you type: nested objects become [tables], arrays of objects become [[arrays of tables]], and strings, numbers and booleans keep their types. Nothing is installed or uploaded, because the conversion runs in your browser.
TOML (Tom's Obvious Minimal Language) is a configuration format meant to be read and edited by people. It has comments, integers that are distinct from floats and a native date type, and it avoids YAML's indentation rules. Rust's Cargo, Python packaging, Hugo and Netlify all use it. The catch is that TOML and JSON do not line up one-to-one, and the sections below spell out exactly where they differ so there are no surprises in your output.
.json file. You can also drag a file onto the editor.config.toml.This JSON describes a small Rust project. In the output, the package and dependencies objects become tables, the two bin objects become an array of tables, and debug moves to the top (the reason is explained below).
{
"package": {
"name": "my-app",
"version": "0.1.0",
"authors": ["Ada Lovelace"]
},
"dependencies": {
"serde": "1.0",
"tokio": { "version": "1", "features": ["full"] }
},
"bin": [
{ "name": "server", "path": "src/main.rs" },
{ "name": "worker", "path": "src/worker.rs" }
],
"debug": false
}debug = false [package] name = "my-app" version = "0.1.0" authors = [ "Ada Lovelace" ] [dependencies] serde = "1.0" [dependencies.tokio] version = "1" features = [ "full" ] [[bin]] name = "server" path = "src/main.rs" [[bin]] name = "worker" path = "src/worker.rs"
| JSON | TOML output | Notes |
|---|---|---|
| Object at the top level | key = value lines | The document itself is the root table. |
| Nested object | A [table] header; deeper levels get [a.b] | An empty object is still written, as an empty [table]. |
| Array of objects | Repeated [[table]] headers | One header per item; nested objects inside an item become sub-tables. |
| Array of scalars or arrays | Inline: [ 80, 443 ] | An empty array is []. |
| String | "text" | Quotes, backslashes, tabs, newlines and control characters are escaped. |
| Integer | 42 | A value such as 1.0 is written as 1 (see below). |
| Decimal number | 1.5 | Large or tiny values keep exponent form, such as 1e-7. |
| true / false | true / false | Always lower case. |
null | Omitted | TOML has no null type; see below. |
| ISO date string | A string (default) | Becomes a TOML date only if you tick the dates option. |
JSON can say "proxy": null; TOML has no way to write that. By default this converter leaves such keys out, which is how most TOML libraries behave, so a missing key stands for no value. Null items inside an array are dropped too, which means the items after them move up one position.
If a missing key would change what your program does, set Null values to Report an error. The status bar then names the first null it finds, for example servers[1].proxy, so you can decide on a replacement such as an empty string or a default.
A TOML file is a set of key/value pairs, so the root has to be an object. A JSON array or a bare string, number or boolean at the top level cannot be converted as is, and the converter says so instead of guessing. Type a name into Wrap in key and the whole value is nested under it: [1, 2] with the key ports gives ports = [ 1, 2 ], and an array of objects with the key products becomes a series of [[products]] tables.
When every item in an array is an object, the natural TOML form is a [[name]] header per item, as in the [[bin]] entries above. If an array mixes objects with other values, TOML cannot use that form, so the converter writes the objects as inline tables: a = [ { x = 1 }, 2 ].
In TOML, once a [table] header appears, every following key belongs to that table. To keep the meaning intact, plain values must be written before any tables, so a key such as debug that comes after an object in your JSON is moved up to the top. Within each group the original order is kept. JSON objects are unordered by definition, so no data changes.
TOML keys written without quotes may only contain ASCII letters, digits, underscores and hyphens. Anything else is quoted automatically: "build info" for a space, "a.b" for a dot (which would otherwise mean a nested table), "é" for non-ASCII letters and "" for an empty key. Digit-only keys such as 123 are valid bare keys and stay unquoted.
TOML separates integers from floats, while JSON has a single number type. Whole numbers such as 3 are written as integers, and so is 1.0 (as 1), because the browser's JSON parser does not preserve the trailing .0. Numbers with a fractional part, such as 1.5, stay floats.
JavaScript numbers are exact only up to 9,007,199,254,740,991. Larger whole numbers are written as floats with the nearest representable value, so 9007199254740993 becomes 9007199254740992.0. If you rely on 64-bit IDs, store them as strings in your JSON before converting.
TOML has native offset date-times, local dates and local times; JSON does not, so a date in JSON is just a string. The converter keeps it a string by default, because a parser that reads the TOML will then give you the same string back. Tick ISO dates as TOML dates and strings in the forms 2024-01-15, 2024-01-15T10:30:00Z (also with an offset or without a zone) and 10:30:00 are written as real TOML dates. Date-times always get a fractional part, so 10:30:00Z becomes 10:30:00.000Z, and impossible dates such as 2024-02-30 stay strings.
JSON is the better choice for data that programs exchange: it is everywhere, it nests freely and any value can be null. TOML is the better choice for files that people maintain: you can comment it, the sections are labeled, and there are no braces or commas to forget. TOML is also stricter, with a table at the root and no null, which is why a JSON to TOML conversion sometimes needs a decision from you. For a similar comparison with YAML, see YAML vs JSON.
If you need sample data to try the converter with, create some with the JSON Generator, or check its structure first with the JSON Schema Generator. To go the other way, use the TOML to JSON converter. Other config formats are covered by the JSON to YAML converter and the JSON to XML converter.
Paste your JSON into the JSON Input editor, or upload a .json file. The TOML appears in the output editor as you type. Copy it, or click Download to save it as config.toml.
TOML has no null type, so by default the converter leaves out any key whose value is null, and drops null items from arrays. If you would rather find those values than lose them, set Null values to Report an error and the status bar names the path of the first null.
Not directly, because a TOML document must be a table at the top level. Type a key into Wrap in key (for example products) and the whole array is written under it, as an array of tables if it holds objects.
JSON is a compact data-exchange format with null, no comments and no date type. TOML is designed for hand-edited configuration: it allows comments, distinguishes integers from floats, has native dates and times, and has no null. TOML is not a drop-in replacement for JSON, because every document must be a table at the top level.
Not by default. A string such as 2024-01-15T10:30:00Z stays a string, so the TOML means what your JSON meant. Tick ISO dates as TOML dates to write valid ISO 8601 dates, date-times and times as native TOML values instead.
Yes. Use the TOML to JSON converter, or click Swap direction above the editors. TOML dates become ISO strings in the JSON, since JSON has no date type.
No. The conversion runs entirely in your browser with JavaScript, so your data never leaves your device. That makes it safe to use with config files that contain internal hostnames or other private values.