TOML to JSON

Convert TOML to JSON format

About TOML to JSON

TOML to JSON parses pasted TOML, such as a Cargo.toml or pyproject.toml, with the smol-toml parser and writes the result as JSON indented by two spaces. Tables and dotted keys become nested objects, arrays of tables become arrays, and inline tables become objects. Dates and times become ISO 8601 strings with milliseconds, integers keep every digit, and inf or nan, which JSON cannot hold, are written as null with a notice. A syntax error is reported with the lines around it. The text you paste does not leave your browser.

Example

A Cargo-style TOML file with an inline table, a large integer, and a date-time, and the JSON the tool returns:

TOML

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

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

[limits]
max_id = 9007199254740993
started = 2024-01-15T09:30:00Z

JSON

{
  "package": {
    "name": "demo",
    "version": "0.1.0"
  },
  "dependencies": {
    "serde": {
      "version": "1.0",
      "features": [
        "derive"
      ]
    }
  },
  "limits": {
    "max_id": 9007199254740993,
    "started": "2024-01-15T09:30:00.000Z"
  }
}

How to convert TOML to JSON

  1. 1Paste TOML into "TOML input".
  2. 2Click "Convert".
  3. 3Read the JSON in "JSON output", or the error, which quotes the lines around the mistake.
  4. 4Copy the JSON with "Copy", or press "Download" for data.json.

Formats and limits

Input
TOML text
Output
JSON indented by two spaces, downloaded as data.json
Dates and times
ISO 8601 strings, such as 2024-01-15T09:30:00.000Z
inf and nan
written as null, with a notice

Where your file is processed

The TOML is parsed and turned into JSON in this browser tab; the text is not uploaded, which matters for files that list private package sources. If parsing or copying fails, we receive the error text with quoted text masked, the tool name, and your browser and its version.

Frequently asked questions

Can I download the JSON as a file?

Yes. Once the conversion is done, "Download" saves data.json, and "Copy" puts the same text on your clipboard. Leaving the page before taking the result makes the browser ask you to confirm first.

Are big integers rounded?

No. An integer beyond what a JavaScript number holds exactly, such as 9007199254740993, is read as a big integer and written digit for digit. Decimals are ordinary numbers, so 1.10 is written 1.1.

Are TOML dates kept?

Yes, as ISO 8601 strings: 2024-01-15T09:30:00Z becomes 2024-01-15T09:30:00.000Z, an offset such as -07:00 is kept, a local date stays 2024-01-15, and a local time gets milliseconds. Digits below the millisecond are dropped.

Does the error show where my TOML is wrong?

Yes. The message starts with Invalid TOML and quotes the numbered lines around the problem, with a caret under the place where the parser stopped.

Tips and tricks

  • ✓To go back, paste the JSON into JSON to TOML; keys whose value is null are left out there.

Related tools