TOML to JSON Converter

Paste a Cargo.toml, pyproject.toml or any TOML file and read it as plain JSON. A strict TOML 1.0 parser runs in your browser, so private configs stay private.

TOML → JSON

Input

Settings

History

Load from URL

Why read TOML as JSON

TOML is easy to edit, but tooling around it is thinner than around JSON. Converting lets you:

  • Query a manifest with jq or JSONPath, for example to list every dependency version.
  • Feed configuration into code or a validator that only understands JSON.
  • See exactly how dotted keys and table headers nest — a common source of confusion when a key ends up in the wrong table.

The result is ordinary JSON with two-space indentation, ready to paste into the JSON formatter or an API request.

How TOML maps onto JSON

  • The document root is a table, so the output is always a JSON object.
  • [table] and [a.b] headers become nested objects; dotted keys such as site."google.com" = true also nest, with quoted parts kept as single keys.
  • [[array]] blocks become a JSON array of objects, one per block, in order.
  • Inline tables and arrays map to objects and arrays directly.
  • Integers in hex (0xDEADBEEF), octal (0o755) or binary (0b1101), and those with underscores (1_000_000), become plain decimal numbers.
  • Integers beyond 2^53, which TOML allows up to 64 bits, keep every digit in the JSON instead of being rounded.
  • Multi-line basic and literal strings become ordinary JSON strings with \n escapes.

Dates, times and special floats

JSON has no date type, so all four TOML date-time kinds become strings:

  • Offset date-times keep their offset: 1979-05-27T07:32:00-08:00 becomes "1979-05-27T07:32:00.000-08:00".
  • Local date-times are written with a T separator and no offset, and local dates stay "1979-05-27".
  • Local times become strings such as "07:32:00.000".

Note that fractional seconds are stored with millisecond precision: a value like 07:32:00.999999 comes out as .999. If microseconds matter, keep those values as strings in the TOML.

TOML’s inf, -inf and nan have no JSON representation and are written as null.

Strict parsing

The parser follows TOML 1.0 to the letter, so it rejects documents some lenient tools accept: defining the same key twice, reopening a table with a second [a] header, or defining [a.b] after b was already set as a value inside [a]. Each error carries a line and column so you can jump straight to it. Comments are allowed in the input but have no place in JSON, so they are dropped.

Options and next steps

There is nothing to configure. Use the TOML formatter to tidy the source first, JSON to TOML to go back, or TOML to YAML if the destination is a YAML-based tool. All three work offline once the page has loaded, and none of them uploads your input.

Examples

Cargo manifest

Inline tables become nested objects and the two [[bin]] blocks become a two-element array.

Input
[package]
name = "ledger"
version = "0.4.1"
edition = "2021"

[dependencies]
serde = { version = "1", features = ["derive"] }
anyhow = "1.0"

[[bin]]
name = "ledger"
path = "src/main.rs"

[[bin]]
name = "ledger-admin"
path = "src/admin.rs"
Output
{
  "package": {
    "name": "ledger",
    "version": "0.4.1",
    "edition": "2021"
  },
  "dependencies": {
    "serde": {
      "version": "1",
      "features": [
        "derive"
      ]
    },
    "anyhow": "1.0"
  },
  "bin": [
    {
      "name": "ledger",
      "path": "src/main.rs"
    },
    {
      "name": "ledger-admin",
      "path": "src/admin.rs"
    }
  ]
}
Open this example in the tool

Dates, number bases and big integers

Shows date-times turned into strings, hex/octal/binary normalised to decimal, the large ID kept exact and inf written as null.

Input
released = 1979-05-27T07:32:00-08:00
backup_window = 03:30:00
flags = 0b1101
mode = 0o755
max_id = 9007199254740993
ratio = inf
Output
{
  "released": "1979-05-27T07:32:00.000-08:00",
  "backup_window": "03:30:00.000",
  "flags": 13,
  "mode": 493,
  "max_id": 9007199254740993,
  "ratio": null
}
Open this example in the tool

Common errors and how to fix them

ErrorCauseFix
Trying to redefine an already defined table or value
Explained
A key is assigned twice, or a table header such as [server] appears more than once.Merge the two definitions into one table, or rename one of the keys.
Invalid valueA value is written without quotes, for example key = value instead of key = “value”.Quote string values. Only numbers, booleans, dates, arrays and inline tables may be unquoted.
Each key-value declaration must be followed by an end-of-lineExtra text follows a value on the same line, often a missing # before a comment.Put each key/value pair on its own line and start comments with #.
Unfinished stringA string is opened with a quote that never closes on the same line.Add the closing quote, or use triple quotes for a multi-line string.

Frequently asked questions

How are TOML dates represented in JSON?

As strings, because JSON has no date type. Offset date-times keep their UTC offset, and local dates and times are written without one.

Are TOML comments preserved?

No. They are read and discarded, because JSON cannot contain comments.

Will a 64-bit integer be rounded?

No. Integers too large for a JavaScript number are printed with their exact digits.

Why does the converter reject a file that my tool accepts?

Some tools are lenient about duplicate tables or keys. This converter follows TOML 1.0 strictly, so the error points at the definition the spec forbids.

Related tools