Skip to content
AZ Tools

TOML ↔ JSON Converter

Convert between TOML (Cargo.toml, pyproject.toml, Hugo configs) and JSON — handles tables, array-of-tables, inline tables, typed scalars.

How to use

  1. Pick a direction. TOML → JSON parses your TOML into a JSON object; JSON → TOML does the reverse.
  2. Paste the source. Errors point to the line / character that broke parsing.
  3. Copy the result. The TOML output groups scalars first, then [table] sections, then [[array.of.tables]] blocks — the order most linters expect.

About this tool

Show

TOML and JSON describe the same shape of configuration data with very different syntax, and this converter walks both directions. Paste a Cargo.toml or a pyproject.toml to get the JSON your linter, generator or script expects, or feed it JSON and get the TOML that Rust and Python tooling actually ships. It handles the parts of TOML that turn up in real files: tables [a.b], arrays of tables [[a.b]], inline tables, inline arrays, basic and literal strings, integers, floats with underscore separators, booleans and dates.

The conversion is not symmetric, and the asymmetry is TOML's missing null. JSON has one, TOML does not — the convention there is to omit the key entirely. Going from JSON to TOML this tool writes an empty string rather than dropping the key, so the structure survives and the distinction between "absent" and "explicitly nothing" does not. If that difference carries meaning in your schema, handle those keys before converting rather than after.

Dates are the other place the two formats genuinely disagree. TOML has first-class date and time types, including a local date-time that deliberately carries no offset; JSON has only strings. This converter keeps a date-time verbatim as it was written, which is a deliberate choice rather than laziness: parsing one into a date object and formatting it again would resolve that missing offset against the viewer's time zone, so the same pyproject.toml opened in Seoul and in Lisbon would produce two different JSON documents. Keeping the text means the value that arrives is the value that was there.

Two smaller notes. TOML integers are 64-bit signed by specification while JSON numbers are doubles in most parsers, so a value past 2^53 does not survive the round trip intact in JavaScript — a build number or a snowflake ID is the usual casualty. And a.b = 1 and [a] with b = 1 mean exactly the same thing in TOML, so two files that look nothing alike can convert to identical JSON, which is worth remembering before concluding that a diff has found a real change.

Frequently asked questions

Does it cover the full TOML spec?

It handles tables, dotted keys, inline tables, inline arrays, multi-line arrays, basic strings, multi-line basic strings, literal strings, integers with _ separators, floats, booleans, RFC 3339 datetimes, and array-of-tables. Less common features (offset datetime arithmetic, escape sequence edge cases, very deeply nested mixed values) round-trip but may need a hand-edit.

Why does JSON → TOML reorder my keys?

TOML requires scalars to come before any [table] block within a section, because once [table] opens the next set of keys belongs to it. The serializer rearranges scalars first so the output parses back correctly — your top-level field meaning doesn't change.

Why does a value I meant as text come back as a date or a number?

Because TOML types bare values by their shape: a bare 2026-03-15 is a date, 1.20 is a float that prints as 1.2, and 0x1F is an integer. Anything whose exact text matters — a version, a phone number, an identifier with a leading zero — has to be quoted. It is the same trap YAML sets, with a stricter and better-specified set of rules behind it.

Which TOML shape does an array of objects become?

An array of tables, written as repeated double-bracket headers rather than as a bracketed list. The result is verbose but readable, which is the trade TOML makes throughout. Round-tripping through JSON therefore does not preserve your original layout: comments are lost, inline tables may come back expanded, and key order follows the document rather than what you wrote.

Related tools