JSON to TOML Converter

Convert JSON to TOML with correct table headers, array-of-tables syntax and value types. Paste JSON, get valid TOML for Cargo, pyproject or app config.

Loading tool…

Worked examples

  • A small config object

    The simplest case: flat keys become one TOML key-value line each, matching how tools like Cargo.toml or pyproject.toml are written.

  • Nested objects and an array become a TOML table

    TOML represents nested objects as [table] headers rather than indentation, and arrays as inline bracketed lists — a common surprise for people used to YAML.

  • An array of objects becomes an array of tables

    TOML has a dedicated [[array of tables]] syntax for arrays whose items are objects, which this converter produces automatically.

What this converter does

TOML and JSON represent the same underlying data — tables, arrays, strings, numbers, booleans — but TOML uses [section headers] for nesting instead of braces, and has a dedicated syntax for arrays whose entries are themselves tables. This tool parses your JSON and rewrites it as valid TOML, applying those structural rules automatically instead of leaving you to translate them by hand.

When you need it

  • Writing a Cargo.toml (Rust), pyproject.toml (Python) or .toml-based app config by starting from a JSON object you already have.
  • Converting a config object your code generates as JSON into the TOML format a tool or framework requires.
  • Migrating a project's config from JSON to TOML for the improved readability TOML offers with deeply nested settings.

Rules the converter applies

  1. The JSON must be an object at the top level. TOML documents are always a table, so a JSON array or a bare string/number at the root can't be represented and is rejected.
  2. Nested objects become [section] headers, not indented blocks. This is the single biggest structural difference from JSON or YAML, and the thing to double-check in the output if you're new to TOML.
  3. An array of plain values (numbers, strings) becomes an inline bracketed array — ports = [ 8080, 8443 ] — written on one line, matching how TOML represents simple arrays.
  4. An array of objects becomes a TOML array of tables, written as repeated [[name]] blocks — TOML's dedicated syntax for "a list of records," which has no equivalent bracket syntax the way JSON does.
  5. Key order at each level is preserved, though TOML's own conventions typically put standalone key-value pairs before nested [section] blocks, and the underlying library follows that convention.

JSON and TOML side by side

| JSON | TOML | Note | |---|---|---| | {"a": 1} | a = 1 | Flat key becomes a key-value line | | {"b": {"c": 1}} | [b]
c = 1 | Nesting becomes a section header | | {"d": [1, 2]} | d = [ 1, 2 ] | Simple array stays inline | | {"e": [{"f": 1}]} | [[e]]
f = 1 | Array of objects becomes array-of-tables |

Things to check after converting

  • TOML has no null. A JSON null anywhere in the document (including inside an array) stops the conversion with the path of the offending value, because dropping it silently would change your data. Remove the key or substitute a placeholder.

  • JSON does not distinguish 1 from 1.0, so a whole-number float comes out as a TOML integer (1), and integers beyond about 9 × 10^15 are rounded before they reach TOML.

  • If a JSON key isn't a valid bare TOML key (spaces or special characters), the output quotes it — verify the tool reading your TOML supports quoted keys.

  • TOML has first-class date and datetime types; JSON date strings stay as quoted strings rather than becoming native TOML dates. Convert them manually if needed.

  • An empty top-level JSON object produces an essentially empty TOML file — check that's actually what you intended.

Limits

Input is capped at 2 MB. Extremely deep nesting (many levels of objects inside objects) is valid TOML but becomes harder to read with section headers than it was with JSON's braces — consider flattening deeply nested config before converting if readability matters more than a mechanical translation.

Frequently asked questions

Is my JSON uploaded anywhere?
No. The conversion runs entirely in your browser; nothing is sent to a server.
Why does my nested object become a [section] header instead of staying indented?
TOML represents nesting with table headers, not indentation. This is the main structural difference from JSON or YAML.
What happens to an array of objects?
It becomes a TOML array of tables, written as repeated [[name]] blocks — the standard way TOML represents that shape.
What happens to null values?
TOML has no null type, so the tool stops and tells you which key holds the null instead of silently dropping it. Remove the key or give it a placeholder value, then convert again.
Can the top-level JSON be an array?
No — TOML documents must be a table (object) at the root, so the input JSON must be a JSON object.