Tooleux

TOML to JSON

Convert TOML to JSON and back. Supports all TOML types. Reports errors with line numbers.

Runs in your browser. Nothing leaves your device.
Convert TOML to JSON and back. Exact conversion, clear error reporting, no uploads or tracking. Read more Show less

What is TOML?

TOML (Tom's Obvious Minimal Language) is a configuration file format designed to be unambiguous, easy to read, and easy to parse. It was created in 2013 by Tom Preston-Werner and is now governed by a specification at toml.io.

TOML is the default configuration format for Rust (Cargo.toml), Python (pyproject.toml), and Hugo, and it is commonly used for static site generators, build tools, and any application that wants a middle ground between INI files and YAML. It avoids YAML's ambiguity (no tabs, no surprising type coercion) while being more expressive than INI.

How to use

Choose the direction: TOML to JSON or JSON to TOML. Paste into the input. The conversion is exact where the data allows it, and reports clear errors where it does not.

TOML to JSON. Comments are dropped (JSON has no comment syntax). Dates become ISO 8601 strings. Multi-line strings become single strings. Tables and inline tables become nested JSON objects. Arrays of tables become JSON arrays.

JSON to TOML. The JSON must be an object at the top level, because TOML requires a root table. Null values are not supported by TOML and are silently dropped from the output. Integers above 2^53 are rejected rather than silently losing precision.

TOML vs YAML vs JSON

JSON is unambiguous, universally supported, and unpleasant to write by hand. No comments, verbose quoting, and quotes around every key. Use it for data interchange.

YAML is pleasant to write and dangerous to guess at. The Norway problem, indentation rules, and the many ways to write the same value make it easy to produce documents that mean something different than intended. Use it when a tool requires it.

TOML is pleasant to write and unambiguous to parse. No tabs, no implicit type coercion, no significant whitespace. It is stricter than YAML, which is the point. Use it for configuration files where correctness matters more than flexibility.

TOML's type system

TOML has explicit types and does not perform implicit coercion:

  • String - basic (double-quoted), literal (single-quoted), multi-line basic, or multi-line literal. Escapes only work in the basic forms.
  • Integer - signed 64-bit. Underscores allowed as visual separators: 1_000_000.
  • Float - IEEE 754 double-precision. inf and nan are valid.
  • Boolean - true and false, lowercase only.
  • Offset Date-Time - RFC 3339 with offset, e.g. 1979-05-27T07:32:00Z.
  • Local Date-Time - same without offset.
  • Local Date, Local Time - date and time components on their own.
  • Array - mixed types are allowed.
  • Table - [table.name] headers, nested by dotted paths.
  • Inline Table - { key = "value" } on one line.
  • Array of Tables - [[items]] repeated.

TOML does not have a null type. This is a deliberate choice by the specification, not an oversight.

FAQ

Why is TOML called "Tom's Obvious Minimal Language"?

Because "Tom's Obvious Minimal Language" parses to TOML, and TOML is meant to be obvious to a human reading the file. The name is a bit of a joke at the expense of XML, which is famously not obvious.

Does TOML support comments?

Yes. Lines beginning with # are comments and run to the end of the line. They are stripped when converting to JSON, but preserved when the source is a TOML file and the destination is TOML.

Can I have null values in TOML?

No. The TOML specification deliberately omits null. If you need to represent "absent", either leave the key out or use a sentinel value like an empty string.

Why does JSON to TOML require an object at the top level?

Because TOML documents are tables at the root. A top-level JSON array, string, or number has no equivalent in TOML. Wrap it in an object: { "items": [...] }.

Are dates preserved through TOML to JSON?

Dates become ISO 8601 strings in JSON, because JSON has no date type. Converting back to TOML produces the same date value. The round-trip preserves the data, not the type information.

What about very large integers?

TOML integers are signed 64-bit. JSON numbers are double-precision floats, which lose precision above 2^53. Converting JSON to TOML, integers above 2^53 (JavaScript's safe integer limit) are rejected with an error rather than written imprecisely. The library refuses to silently lose precision. Integers at or below 2^53 are written correctly.

Command line equivalent
# Python
python3 -c 'import tomllib, json, sys; print(json.dumps(tomllib.loads(sys.stdin.read()), indent=2))' < input.toml

# Python (write direction)
pip install tomli-w
python3 -c 'import tomli_w, json, sys; print(tomli_w.dumps(json.load(sys.stdin)))' < input.json

# Node
npm i smol-toml
node -e 'const TOML=require("smol-toml"), fs=require("fs"); console.log(JSON.stringify(TOML.parse(fs.readFileSync("input.toml","utf8")), null, 2))'

# Go
go get github.com/BurntSushi/toml
# see package docs

# Rust (cargo itself uses TOML)
# use the toml crate directly
Loads a test value into the form
TOML
JSON