TOML to JSON Converter

Paste TOML, such as a Cargo.toml or pyproject.toml, or open a file and press Convert to JSON. Errors are reported with their line number, and a tree shows how the TOML maps to JSON.

Try an example
The file is read in your browser and placed in the box.

About this TOML to JSON converter

TOML is a configuration format designed to be easy to read: Rust’s Cargo.toml, Python’s pyproject.toml, Hugo sites, and many apps use it. Sometimes you need the same data as JSON, to feed an API, a script, or a tool that does not read TOML. This converter implements the TOML 1.0 specification, including dotted keys, [tables] and [[arrays of tables]], inline tables, basic, literal, and multi-line strings, integers with underscores in decimal, hex, octal, and binary, floats with inf and nan, and offset, local, date-only, and time-only values. Dates become ISO strings and inf and nan become text, since JSON has no such values. Rule breaks such as duplicate keys are reported with their line.

How to convert TOML to JSON

  1. Add your TOML. Paste a config file, open a .toml file, or press an example such as Cargo.toml.
  2. Pick the output style. Choose 2 or 4 spaces, a compact single line, or sorted keys for easier comparison.
  3. Press Convert to JSON. Copy or download the JSON and explore the structure tree. Fix any error at the line shown and convert again.

Frequently asked questions

How are TOML dates converted?

JSON has no date type, so dates and times become ISO 8601 strings, for example 1979-05-27T07:32:00Z. A space between date and time is replaced by T.

What does [[name]] become in JSON?

An array of tables becomes a JSON array of objects. Each [[bin]] header adds a new object to the bin array, in order.

What happens to very large integers?

TOML allows 64-bit integers, but JSON numbers in JavaScript lose precision above 9,007,199,254,740,991. Larger integers are written as strings so no digits are lost.

Why is my TOML rejected for a duplicate key?

TOML does not allow the same key or table to be defined twice, including defining [server] in two places. Merge the entries into one table.

Are comments kept?

No. JSON does not support comments, so lines starting with # and comments after values are left out of the result.