TOML to JSON Converter

Convert between TOML and JSON, from text or a file.

About TOML to JSON Converter

Convert TOML to JSON or JSON to TOML in the browser, with tables, arrays of tables and dates handled and the direction detected as you type.

How to use

  1. Paste TOML or JSON, or load a .toml or .json file (up to 5 MB) with the file picker or by dropping it on the page.
  2. Input that starts with { is read as JSON and converted to TOML; anything else is read as TOML. Use the Auto / TOML → JSON / JSON → TOML switch to force a direction.
  3. For JSON → TOML, tick "write ISO date strings as TOML dates" if strings such as 2024-01-31 should become TOML dates instead of quoted strings.
  4. The output updates as you type. Copy it, or Download it as .json or .toml named after the loaded file.

What it does

  • Parsing and writing are done by smol-toml, which implements TOML 1.1.
  • TOML → JSON: tables and inline tables become objects, and arrays of tables ([[name]]) become arrays of objects. The output is indented with two spaces.
  • TOML dates become JSON strings. An offset date-time keeps its offset (1979-05-27T07:32:00.000-08:00), a local date stays 1979-05-27 and a local time becomes 07:32:00.000. Times are written to the millisecond; finer fractions are dropped.
  • JSON → TOML: nested objects become [table] sections, arrays of objects become [[arrays of tables]], and other arrays are written inline. The plain values of a table are written before its sub-tables, so key order can change.
  • With the date option on, a string is written as a TOML date only if it is a complete, real date, date-time or time; 2023-02-29 and 1.2.3 stay strings.
  • TOML has no null. JSON that contains null is not converted; the error says where the nulls are.
  • JSON has no inf or nan, so TOML that contains them is refused in the same way. A TOML integer beyond 2^53 is refused with its position rather than rounded.
  • The JSON root must be an object, because a TOML document is a table.
  • A TOML syntax error names the line and column.
  • Comments are not carried into JSON, and a trip through JSON does not bring back comments, inline-table style or the original layout.

Example

title = "xutil"

[owner]
name = "Ada"
joined = 2024-01-31
→
{
  "title": "xutil",
  "owner": {
    "name": "Ada",
    "joined": "2024-01-31"
  }
}

Privacy

Conversion runs in the page. A dropped file is read locally, no request is made, and nothing is stored.

Frequently asked questions

Does TOML support null?
No. TOML has no null value, so a key is either present with a value or absent. When converting from JSON, remove the keys whose value is null or replace the null with a placeholder your program understands, such as an empty string.
What is the difference between a table and an inline table in TOML?
They hold the same data. A table is a [name] header followed by key = value lines; an inline table writes the pairs inside braces, as in point = { x = 1, y = 2 }. Both become the same JSON object.
How are arrays of objects written in TOML?
As an array of tables: each object gets its own [[name]] header followed by its keys. Two [[fruit]] sections become a JSON array named fruit that holds two objects.
How does TOML represent dates?
Dates are a native type written without quotes: an offset date-time such as 1979-05-27T07:32:00Z, a local date-time, a local date or a local time. JSON has no date type, so they become strings there.