How to Convert JSON to TOML (and TOML to JSON)

TOML and JSON both have explicit types and no significant whitespace, which makes conversion predictable. The main difference is how TOML expresses nesting with tables.

How nesting maps

A nested JSON object becomes a TOML table written with brackets:

{
  "title": "App",
  "database": { "host": "localhost", "port": 5432 }
}

becomes

title = "App"

[database]
host = "localhost"
port = 5432

Top-level scalar keys come first, then each nested object becomes its own table section.

Arrays of objects

A JSON array of objects maps to a TOML array of tables using double brackets:

{ "workers": [ { "name": "w1" }, { "name": "w2" } ] }

becomes

[[workers]]
name = "w1"

[[workers]]
name = "w2"

TOML to JSON

Going back, every table becomes a nested object and every array-of-tables becomes an array of objects. TOML's explicit types carry over cleanly — no surprise coercion like YAML.

Gotchas

  • Deeply nested data gets verbose in TOML; JSON or YAML may read better.
  • Mixed-type arrays are restricted in older TOML versions — keep elements the same type.
  • Comments are dropped when converting to JSON.

Do it instantly

Paste your file into the formatter, choose TOML or JSON as the target, and copy. It auto-detects the source and handles tables and arrays-of-tables for you.

Got a config file to check?

Open the config toolkit →