Tools

TOML to JSON converter

Convert TOML to JSON and JSON back to TOML — Cargo.toml, pyproject.toml and the rest — with tables and dates intact.

Runs in your browserData formats308
Free

Input

0 B

Result

The result will appear here.

TOML is what Cargo.toml, pyproject.toml, netlify.toml and many Hugo sites are written in, and sooner or later you need one of those files as JSON — to query it with jq, feed it to a script, or compare two versions structurally. This converts in both directions with smol-toml, a small parser and serialiser for TOML 1.1 that passes most of the official toml-test suite; the specification itself lives at toml-lang/toml. Syntax errors name the line and column, and the converter stops, naming the exact key, rather than silently losing something one format cannot express.

How it works

  • Inline tables, dotted keys and arrays of tables such as [[bin]] all become ordinary nested JSON objects and arrays.
  • Offset datetimes become ISO 8601 strings; local dates and times keep the form they were written in, such as 1979-05-27.
  • JSON null has no TOML equivalent, so the converter names the key instead of dropping it, which is what smol-toml would otherwise do.
  • Going to TOML, nested objects become [table] sections and arrays of objects become [[array]] tables.

Where your data goes

Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.

This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.

What it costs

This tool is free, with no sign-in and no points.

Common questions

Why does a null value stop the conversion?
TOML has no null. A converter that quietly skips the key produces a file that looks right and behaves differently, so this one refuses and tells you where, as a path like $.package.homepage. Remove the key, or give it a real value such as an empty string or false.
Why did my datetime come back as a quoted string?
JSON has no date type, so a TOML datetime becomes a string on the way to JSON. Converting that JSON back produces a quoted string rather than a bare TOML date, because nothing in the JSON says it was ever a date. Remove the quotes if the consumer needs a real TOML datetime.
Are comments and key order kept?
From TOML to JSON, key order is kept. From JSON to TOML, the plain keys of each table are written before its sub-tables, because in TOML a key that follows a [table] header belongs to that table. Comments are not kept: they are discarded when the TOML is parsed, since JSON has nowhere to put them, so a round trip through JSON returns the data without the explanations. Keep the TOML file as the source of truth and generate the JSON from it.
What happens to very large integers?
TOML integers are 64-bit, and JavaScript numbers are exact only up to 2^53. Rather than rounding 9007199254740993 to a different number, the parser reports an error. Values like that, such as snowflake IDs, are safer stored as strings. Likewise inf and nan are rejected, because JSON cannot represent them.

The open-source behind it

This tool runs on squirrelchat/smol-toml, released under BSD-3-Clause. If you need the same behaviour inside your own program, that is the library to reach for.

squirrelchat/smol-toml

Also known as

  • toml to json
  • json to toml
  • toml converter
  • toml parser online
  • cargo.toml to json
  • pyproject.toml to json
  • toml validator