JSON to TOML Converter

Paste a JSON object to convert it to TOML.

How it is calculated

The input must be a JSON object (curly braces) with at least one key. A bare list, a single value, an empty object, an object whose values are all null, or invalid JSON shows no result. Each key becomes a TOML line key = value. Strings are double-quoted with escaping, numbers and true/false are written bare, whole-number floats such as 2.0 keep the .0, and lists become [a, b, c]. Nested objects of any depth become [table] or [a.b] sections placed after the plain keys, and a list made only of objects becomes repeated [[name]] blocks. Keys with spaces or other special characters are quoted. TOML has no null, so null members are left out (inside a list, the null item is dropped). The tool also reports how many top-level keys it converted. Check the output before using it in a real config file. A nested empty object becomes an empty table such as [opts], and an empty list stays [].

Worked example

Paste an object with a title, a version number, a boolean, a list and a nested object: {"title":"My App","version":2,"debug":false,"ports":[80,443],"database":{"host":"localhost","port":5432}}. The tool reports 5 keys and writes four plain lines first: title = "My App", version = 2, debug = false, ports = [80, 443]. Then a blank line and the table: [database] followed by host = "localhost" and port = 5432. The nested object became a table, and the text stayed quoted while 2 and false did not.

Try this example →

Common mistakes

  • Pasting a JSON array at the top level, such as [1,2]. The tool needs an object with keys, so it shows nothing.
  • Using single quotes or trailing commas. This is JSON, so strings need double quotes and no trailing comma, otherwise the input is rejected.
  • Expecting null to survive. TOML has no null, so the key is simply omitted; if your program treats a missing key differently from null, add a default by hand.
  • Expecting a list of objects to become an inline array. It is written as repeated [[name]] blocks, which is the same data but looks different.
  • Reading the key count as every key in the file. It counts only top-level, non-null keys, so nested keys are not included.

About this calculator

TOML (Tom's Obvious Minimal Language) is a configuration-file format designed to be trivially readable, and it is the standard format behind Rust's Cargo.toml package manifests, Python's pyproject.toml build configuration, and many other developer tool config files. Converting a JSON object to TOML means re-expressing the same data with TOML's own conventions: string values are quoted, numbers and booleans are written bare, nested objects become [table] sections, and arrays stay in bracketed list form.

This tool performs that structural translation for simple JSON objects automatically, which is useful when migrating a config from a JSON-based tool to a TOML-based one, or when hand-writing TOML from a JSON example without memorizing the syntax differences.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Two details matter when you move the output into a real config. Values that look like dates, such as 2024-01-05, stay quoted strings, so if your program expects a native TOML date you must remove the quotes by hand. Also, plain keys are always written first and tables after them, whatever order they had in the JSON, which is what TOML requires. Which tool's config file are you migrating, and did it parse without edits?

Popular calculators

All Calculators