TOML Formatter
Paste TOML. Format it and keep every comment, check it as you type, get the JSON. Nothing leaves your browser.
- 0
- Tables
- 0
- Keys
- 0
- Errors
On this page
About TOML Formatter
Updated
What is a TOML Formatter?
A TOML Formatter takes your TOML configuration file and gives it a clean, consistent layout. TOML (Tom's Obvious, Minimal Language) is a configuration file format designed to be minimal, unambiguous and easy to read. It is widely used in the Rust and Python ecosystems.
How to use this tool
Type or paste your TOML into the editor and press Format. The formatter puts one space around each =, tidies arrays and inline tables, puts a blank line before each table, and removes extra blank lines. Comments and the order of keys stay as you wrote them. The tool checks your TOML as you type: when something is wrong, it rings the exact spot, gives the line and column, and says what to fix.
Summarize TOML
The Result pane counts the tables, arrays of tables, keys, arrays and dates in your TOML, and shows the nesting depth. Open Notes to see each table and how many keys it holds, next to its line.
Convert TOML to JSON
Open the JSON tab in the Result header to see your TOML as JSON. Copy and Download then take the JSON. TOML dates and times become ISO 8601 strings in the JSON.
Customization
Open Options to indent the keys under each table, keep one or two blank lines, line up the = signs, and sort the keys A to Z inside each table. The tool remembers your choices.
TOML vs JSON vs YAML
TOML, JSON and YAML are all popular data formats, but they serve different purposes. JSON is strict, machine-friendly and used everywhere in APIs. YAML is flexible and easy to read, but its indentation rules cause errors. TOML sits in between: it is made for configuration files and aims to be obvious and unambiguous. Unlike YAML, TOML does not use indentation for structure, and unlike JSON, it supports comments and has an easier syntax for nested data.
Common TOML syntax errors
Missing equals sign
Every key and value in TOML needs an equals sign: key = value. A colon, as in YAML, or no separator at all, is an error.
name: "checkout-api"name = "checkout-api"Duplicate keys
TOML does not allow the same key twice in one table. This is by design, to keep configuration files unambiguous.
[package]
version = "1.0.0"
version = "1.0.1"Invalid table headers
Table headers use single square brackets ([table]), and arrays of tables use double brackets ([[array]]). A missing bracket, or a table defined twice, is an error.
TOML
TOML (Tom's Obvious, Minimal Language) is a configuration file format that is easy to read and write because its meaning is clear. It was created in 2013 by Tom Preston-Werner, a co-founder of GitHub. TOML aims to be a minimal configuration format that is easy to read, maps to a hash table without ambiguity, and is easy to parse in many programming languages.
- The conventional extension for TOML files is
.toml. - The MIME type for TOML files is
application/toml.
Why use TOML?
TOML was designed as a reaction to the complexity and ambiguity of other configuration formats. It puts clarity and correctness before flexibility, which makes it a good choice when predictability matters.
- TOML is minimal and unambiguous. Every valid TOML document has exactly one meaning.
- TOML is easier to write correctly than YAML: there are no indentation traps and no surprising type conversions.
- TOML supports comments with the
#character, so you can document configuration inline. - Types in TOML are explicit. Strings must be quoted, booleans are
trueorfalse, and nothing changes type by itself (unlike YAML 1.1, wherenocan become a boolean). - The strict specification means TOML files behave the same in every parser and language.
Common TOML use cases
- Cargo.toml. The manifest file for Rust projects, with package metadata, dependencies, features and build targets.
- pyproject.toml. The standard Python project configuration file (PEP 621), which replaces
setup.pyandsetup.cfgfor project metadata. - Hugo. The Hugo static site generator accepts TOML for its configuration and front matter.
- Netlify. Netlify uses
netlify.tomlfor build settings, redirects, headers and deploy configuration.
TOML 1.0 specification
TOML v1.0.0 was released on January 12, 2021. It marked the format as stable. The specification defines strings, integers, floats, booleans, dates and times, arrays, tables and inline tables, and TOML 1.0 parsers exist for almost every programming language.
Other TOML resources
- TOML Official WebsiteThe official TOML website with an overview and links to the specification.
- TOML SpecificationThe full TOML specification on GitHub, with the complete syntax and meaning.
- Cargo.toml Reference (Rust)The official Cargo manifest reference for Rust projects, one of the best-known uses of TOML.
- pyproject.toml SpecificationThe Python packaging specification for pyproject.toml: project metadata and build system requirements.
- TOML on WikipediaHistory, design goals, and comparisons to other configuration formats.
- Learn X in Y Minutes: TOMLA quick, practical introduction to TOML syntax with annotated examples.
- The TOML RepositoryThe TOML repository with the specification, changelog, and community resources.
TOML FAQ
What TOML features does this formatter support?
It supports the TOML 1.0 specification: tables, arrays of tables, inline tables, multi-line strings, literal strings, dates and times, and all scalar types. It uses the smol-toml library to check the file and convert it to JSON.
Can I use this for Cargo.toml and pyproject.toml?
Yes. It works with all valid TOML files, including Cargo.toml (Rust), pyproject.toml (Python), Hugo and Netlify configuration, and any other TOML file.
Does the formatter keep comments?
Yes. The formatter works line by line, so comments, the order of keys and multi-line strings stay as you wrote them. It only changes spacing, indents and blank lines. After formatting, it reads the result again and checks that the data is exactly the same.
What does TOML stand for?
TOML stands for "Tom's Obvious, Minimal Language". It is named after its creator, Tom Preston-Werner, and the name states its goal: obvious and minimal, easy to read and write without ambiguity.
Is TOML a superset of JSON?
No. Unlike YAML, TOML is not a superset of JSON. It has its own syntax. TOML can hold the same data as JSON (strings, numbers, booleans, arrays and objects, called tables), and it adds comments, dates and multi-line strings.
Are tabs allowed in TOML?
Yes. TOML does not use indentation for structure, so tabs and spaces can be used freely to lay out the file. Whitespace matters only inside strings.
Who created TOML?
TOML was created in 2013 by Tom Preston-Werner, a co-founder of GitHub, as a simpler alternative to YAML, JSON and INI for configuration. The specification is maintained at github.com/toml-lang/toml.
When should I choose TOML over YAML?
Choose TOML when you want configuration that is unambiguous and predictable, such as application settings, package manifests and project files. YAML is better for deeply nested data, files with several documents, and tools where YAML is already the standard, such as Kubernetes, Ansible and Docker Compose.