How to convert TOML to JSON

TOML (Tom's Obvious, Minimal Language) is popular for configuration because it is easy to read and maps cleanly to a table of key-value pairs. JSON is the lingua franca for data interchange. Converting from one to the other is common when you want to feed a config file into a program or API that expects JSON. This guide shows how to do it and what to watch for.

Convert TOML to JSON in three steps

Everything happens locally in your browser. Your configuration, which often contains sensitive values like tokens or connection strings, is never uploaded to a server.

How the structure maps

The mapping is mostly intuitive:

One important rule: TOML always has an object (table) at its root, so the resulting JSON will always be a JSON object at the top level, never a bare array or scalar.

Watch out for dates and times

This is the most common surprise. TOML has first-class date and time types (offset date-time, local date-time, local date, and local time). JSON has no date type at all. When you convert, those TOML dates become JSON strings. That is expected and usually fine, but if a downstream program needs a real date, it will have to parse the string itself.

Comments do not carry over

TOML supports # comments, and JSON does not. Any comments in your TOML are dropped during conversion. If you are keeping the JSON as the new source of truth, make a note of anything important that was previously explained in a comment.

Going the other way

You can convert JSON back to TOML with the same tool by swapping the input and output formats. Because JSON allows arrays and scalars at the top level but TOML requires a root table, JSON that is a bare array or a single value cannot be represented as TOML directly. Wrap it in an object first.

Convert your TOML now

Paste TOML, pick JSON as the output, and you are done, all in your browser.

Open the Formatter