Tools / JSON ↔ TOML Converter

JSON ↔ TOML Converter.

Convert JSON to TOML 1.0 and TOML to JSON, with tables, arrays of tables and exact error positions.

Runs in your browser

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result

About JSON ↔ TOML Converter

The JSON ↔ TOML Converter moves configuration between the two formats without guessing. JSON objects become TOML tables, arrays of objects become arrays of tables written as [[name]] blocks, and plain values are written before sub-tables, which TOML requires: a key placed after a [table] header would otherwise belong to that table. For example {"package": {"name": "app"}, "bin": [{"name": "cli"}]} becomes a [package] table and a [[bin]] entry. In the other direction a full TOML 1.0 parser reads basic, literal and multi-line strings, hexadecimal, octal and binary integers with underscores, floats, booleans, inline tables, dotted keys and all four date-time forms. Dates and times are returned as strings because JSON has no date type, and integers too large for JavaScript are kept as strings so no digits are lost. The most common mistakes are reported with their line and column: defining the same key or table twice, reopening an inline table, extending a table created with dotted keys, unquoted string values and trailing commas inside inline tables. TOML has no null, so JSON that contains null is rejected with the path of the offending value instead of silently dropping it. Comments are not part of the data model and are not carried over to JSON. This makes the tool handy for Cargo.toml, pyproject.toml, netlify.toml and Hugo configs. Conversion happens entirely in your browser.

How to Use

  1. Paste JSON or TOML and choose the direction.
  2. Fix any error shown with its line and column.
  3. Copy or download the result.

Frequently Asked Questions

What happens to null values?

TOML has no null type, so the converter stops and names the path of the null value. Remove the key or replace the value, then convert again.

How are TOML dates converted to JSON?

Offset date-times, local date-times, local dates and local times are copied as strings exactly as written, for example "1979-05-27T07:32:00-08:00".

Are comments kept?

No. Comments are not part of TOML data, so they cannot be represented in JSON. Use the TOML formatter if you only want to tidy a file and keep its comments.

Does it run offline?

Yes. Parsing and conversion run in your browser; nothing is uploaded.

Related Tools