Choose language

JSON to TOML Converter

Convert JSON data into clean TOML configuration. Handles nested tables, arrays of tables, and inline tables for Cargo, Poetry, and Hugo configs.

Mehmet Demiray Published Updated
Share
Write whole numbers with a decimal point

What JSON to TOML Conversion Means

JSON to TOML conversion rewrites structured JSON data into TOML, a configuration format built for readability. You reach for it when a tool expects TOML rather than JSON. Rust's Cargo uses Cargo.toml, Python's Poetry and modern packaging use pyproject.toml, and the Hugo static site generator reads config.toml. The two formats describe the same kind of data, so the mapping is direct. A JSON object becomes a TOML table, key-value pairs stay as keys and values, and a JSON array becomes a TOML array. Where they differ is style. JSON wraps everything in braces and quotes, while TOML uses section headers like [server] and bare keys that read more like a settings file. Converting lets you take an API response or a generated config and drop it straight into a project that only speaks TOML. If you need the reverse direction, the TOML to JSON Converter handles it, and JSON to YAML Converter covers a related format pairing.

How the Converter Builds TOML

The converter first parses your JSON into an in-memory tree, then walks that tree to emit valid TOML. Top-level keys with primitive values become plain assignments. Nested objects turn into TOML tables written with bracketed headers, and deeper nesting produces dotted table names like [database.pool]. Arrays of objects map to arrays of tables, written as repeated [[items]] blocks, which is one of TOML's most distinctive features. Strings, numbers, and booleans carry over directly, and string values that look like ISO timestamps can be represented as TOML datetime literals. The tool also handles edge cases that trip up naive conversions: keys containing spaces or dots get quoted, deeply mixed arrays fall back to inline form, and empty objects render as empty tables. Pasting valid JSON and reading the TOML output side by side makes the structural mapping easy to follow before you commit it to a real config file.

Common Use Cases

Most people convert JSON to TOML to feed a real toolchain. A frontend or API team might receive JSON from a service and need it as a Cargo.toml fragment for a Rust binding, or as part of a pyproject.toml build section. Teams migrating between config systems often have years of JSON settings and want a cleaner TOML version that humans can edit without counting braces. Static site builders running Hugo regularly translate exported JSON into config.toml so the generator can read it. The converter also helps during data interchange, when one system emits JSON and another expects TOML, letting you bridge the two without writing a one-off script. Because the output is plain text, you can paste it into a pull request, a documentation example, or a CI fixture. Pairing it with the JSON Formatter lets you tidy the JSON first, so the resulting TOML is predictable.

JSON and TOML Side by Side

Seeing the same data in both formats clarifies what conversion actually changes. Consider a small config block:

JSON TOML
{ "title": "My App" } title = "My App"
{ "owner": { "name": "Ada" } } [owner] then name = "Ada"
{ "ports": [80, 443] } ports = [80, 443]

The values are identical, but TOML drops the outer braces and promotes objects into named sections. This is why TOML feels natural for configuration: a reader scans section headers instead of tracking nesting depth. JSON keeps its advantage for machine-to-machine transport, where compactness and universal parser support matter more than human editing. Knowing which strengths each format brings helps you decide when a conversion is worth doing and when the original JSON is fine to keep as is for your application.

Limits of the Conversion

Conversion between JSON and TOML is mostly faithful, but a few details deserve attention. TOML has no native null, so JSON null values cannot be represented and are typically dropped or need a placeholder. JSON allows arrays that mix types freely, while TOML arrays are expected to hold a single value type, so heterogeneous arrays may be flattened to strings or rejected. TOML also distinguishes integers from floats, so a JSON number written without a decimal point becomes an integer in the output. Key ordering is not guaranteed to match the source, since TOML groups tables together. None of these limits the everyday case of converting a normal config object, but they matter when your JSON leans on features TOML does not share. When you need a strict round trip, test both directions and confirm the data survives unchanged before relying on it.

The ones we answer the most.

How do I convert JSON to TOML?

Paste or type your JSON into the input area and the tool produces the TOML equivalent right away. You can then copy the result or save it as a .toml file. The conversion runs entirely in your browser, so your data never leaves the page.

What are the key differences between JSON and TOML?

JSON uses braces, brackets, and quoted keys, which makes it compact and easy for machines to parse. TOML uses section headers like [server] and bare keys, which makes it easier for people to read and edit by hand. Both describe the same kinds of data, so most JSON maps cleanly onto TOML tables and key-value pairs.

What happens with nested structures or special characters?

Nested JSON objects become nested TOML tables using dotted headers like [database.pool], and arrays of objects become arrays of tables written as repeated [[items]] blocks. Keys that contain spaces, dots, or other special characters are automatically quoted so the output stays valid. This keeps deeply structured configs intact during conversion.

Is the conversion lossless?

For typical configuration data it is. The main exceptions come from features TOML does not support, such as JSON null values and arrays that mix different value types. Those cases may be dropped or adjusted to fit TOML rules. If you need a guaranteed round trip, convert back with the TOML to JSON tool and confirm the data matches.

Which tools actually use TOML files?

TOML is the config format for Rust's Cargo (Cargo.toml), Python packaging via pyproject.toml, the Hugo static site generator, and many CLI tools. Converting JSON to TOML is handy when you have data in JSON but the target project only reads TOML configuration.

Is my data uploaded to a server?

No. The conversion happens locally in your browser, so the JSON you paste and the TOML you generate stay on your device. That makes it safe to use with private config values or internal settings.