JSON to TOML

Convert JSON to TOML format

About JSON to TOML

JSON to TOML writes a pasted JSON object as a TOML file, the format of Cargo.toml and pyproject.toml. Nested objects become [section] tables, arrays of objects become [[section]] arrays of tables, and other arrays stay inline. Strings, numbers, and booleans keep their types; a date written as a JSON string stays a quoted string. TOML has no null, so a null value on a key is left out and a null inside an array stops the conversion. Integers beyond the TOML range are written as quoted text with a notice. smol-toml writes the TOML inside your browser tab.

Example

A JSON object with a date string, an ID too large for TOML, an array of objects, and a null, and what the tool returns; the last line is the notice shown under the boxes, not part of the TOML:

JSON

{
  "title": "Demo",
  "released": "2024-01-15",
  "owner": {"name": "Ann", "id": 12345678901234567890},
  "servers": [{"host": "a", "port": 8080}, {"host": "b", "port": 8081}],
  "note": null
}

TOML

title = "Demo"
released = "2024-01-15"

[owner]
name = "Ann"
id = "12345678901234567890"

[[servers]]
host = "a"
port = 8080

[[servers]]
host = "b"
port = 8081

Beyond what TOML numbers hold (integers up to 9,223,372,036,854,775,807, floats up to about 1.8e308): owner.id written as text (in quotes) to keep every digit.

How to convert JSON to TOML

  1. 1Paste a JSON object, not an array, into "JSON input".
  2. 2Click "Convert".
  3. 3Read the TOML in "TOML output" and any notice about numbers written as text.
  4. 4Click "Copy", or "Download" to save data.toml.

Formats and limits

Input
JSON object at the top level
Output
TOML text, file data.toml
Integers
up to 9,223,372,036,854,775,807; larger ones become quoted text
null
left out on a key, refused inside an array

Where your file is processed

smol-toml writes the TOML in your browser; the JSON you paste is not uploaded, and the TOML stays on the page until you copy it or save data.toml. Error reports, whether or not a message is shown, carry the cleaned error text, the error type, the tool name, and your browser name and version.

Frequently asked questions

Can TOML hold a JSON null?

No. TOML has no null type, so a key whose value is null is simply left out. A null inside an array cannot be dropped without changing the array, so the tool stops with the message arrays cannot contain null or undefined values.

Can I convert a JSON array?

No, not at the top level: a TOML document is a table of keys, so the tool asks you to wrap the array in an object, for example under an items key. Arrays inside the object are converted normally.

Are ISO date strings turned into TOML dates?

No. JSON has no date type, so 2024-01-15 arrives as a string and is written in quotes, as the example shows. Remove the quotes by hand if you want a TOML date.

Are very large numbers kept?

Yes, digit for digit. An integer above 9,223,372,036,854,775,807, or a float beyond the range of a double, cannot be a TOML number, so it is written as quoted text and a notice names the key.

Related tools