Utilia

TOML to JSON Converter

Convert TOML to JSON and JSON to TOML in your browser. Handles tables, arrays of tables, dates and 64-bit integers. Nothing is uploaded.

Conversion

How to convert TOML to JSON

  1. Choose the direction: TOML → JSON (the default) or JSON → TOML.
  2. Paste your data, or click Open a file to load a .toml or .json file (up to 10 MB).
  3. For TOML → JSON, pick the Indentation (2 or 4 spaces) and decide whether to tick Big integers as strings. For JSON → TOML, keep or untick Omit null values.
  4. Tick Sort keys if you want every table ordered alphabetically.
  5. The result updates as you type; Convert runs it again on demand. Errors show the line and column of the problem.
  6. Copy or download the result. Swap direction moves the output into the input to convert it back.

TOML and JSON side by side

TOML (Tom’s Obvious Minimal Language) is the configuration format behind Cargo.toml in Rust, pyproject.toml in Python, Hugo and Netlify sites, and many command-line tools. It is designed to be read and edited by people, and it maps directly onto a JSON-like tree of tables (objects), arrays and values.

[package]
name = "demo"
version = "0.1.0"

[[bin]]
name = "cli"

becomes

{"package": {"name": "demo", "version": "0.1.0"}, "bin": [{"name": "cli"}]}
  • A [table] header becomes a JSON object, and dotted keys such as a.b.c = 1 become nested objects.
  • An array of tables, [[bin]], becomes a JSON array of objects.
  • Inline tables { x = 1 } and arrays work as you would expect. Comments are dropped, since JSON has none.

Where the two formats differ

Dates and times. TOML has four native date-time types; JSON has none. The converter writes them as ISO 8601 strings and keeps their flavour: an offset date-time stays 1979-05-27T07:32:00.000-08:00, a local date stays 1979-05-27, and a local time stays 07:32:00.000. Fractional seconds are kept to the millisecond. Converting back to TOML gives plain strings, because nothing in JSON marks them as dates.

Integers. TOML integers are signed 64-bit, from −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. JavaScript numbers, used by most JSON parsers, are only exact up to 2^53 (9,007,199,254,740,991). Larger TOML integers are written with all their digits, which is valid JSON, but a program that reads them as doubles will round them; tick Big integers as strings to avoid that. An integer outside the 64-bit range is rejected, as the TOML specification requires.

Special floats. inf, -inf and nan have no JSON form, so they are written as the strings "inf", "-inf" and "nan".

JSON → TOML. A TOML document is always a table, so the JSON must be an object at the top level. TOML has no null: by default null values are omitted and a message tells you how many; untick Omit null values to get an error with the location of the first one instead. JSON does not distinguish 1 from 1.0, so whole numbers become TOML integers, and numbers too large for 64 bits become floats. In recent browsers, big integers in your JSON keep their exact digits.

Frequently asked questions

Is my configuration sent anywhere?

No. The conversion runs entirely in your browser, so API keys or secrets in your configuration files never leave your computer.

Why did the order of my keys change in the TOML output?

TOML requires plain key/value pairs to come before sub-tables in each table, so the converter writes values first, then [tables], then [[arrays of tables]]. The data is the same.

Are TOML comments preserved?

No. JSON has no comments, so they are lost when converting TOML → JSON, and there are none to restore on the way back.

Which TOML version is supported?

TOML 1.0, including dotted keys, inline tables, arrays of tables, hexadecimal, octal and binary integers, and all four date-time types.

Why is my date a string in JSON?

JSON has no date type. ISO 8601 strings are the usual convention, and most languages can parse them directly.