TOML Formatter parses and pretty-prints TOML (Tom's Obvious Minimal Language) configuration files. Paste any TOML to validate its syntax and get properly formatted output with consistent indentation, aligned key-value pairs, and comment preservation. It also converts TOML to JSON and back, making it easy to work with TOML data in JSON-based tools.
TOML is a configuration file format designed to be easy to read due to its obvious semantics. It's used in: Rust's Cargo (Cargo.toml), Python packaging (pyproject.toml), Hugo static site generator, ripgrep's configuration, and many developer tools. TOML supports: key-value pairs, dotted keys (a.b.c), sections ([table] headers), arrays, inline tables ({key='value'}), multi-line strings, and dates/times as first-class types (unlike JSON or YAML).
TOML vs YAML: TOML is more explicit and less ambiguous than YAML (no 'yes'/'no' → boolean surprises). TOML vs JSON: TOML supports comments (# like Python), multiline strings, and date/time literals. TOML vs INI: TOML has a defined spec and type system (INI is loosely defined). TOML's spec (toml.io) is designed to be unambiguous — there's exactly one way to parse each TOML construct.
Format Cargo.toml
Result: [package] / name = "myapp" / version = "0.1.0" → properly aligned key = 'value' pairs
Validate pyproject.toml
Result: [build-system] requires = ['setuptools'] → ✓ Valid TOML / missing quote → ✗ Error at line 3
Convert to JSON
Result: [database] host = 'localhost' port = 5432 → {"database":{"host":"localhost","port":5432}}
What is TOML used for?
TOML's primary use is configuration files in developer tools. Major adopters: Rust — Cargo.toml (package manifest), Python — pyproject.toml (PEP 518/621 build config), Hugo — config.toml (site config), Gitea — app.ini (TOML-like), Starship — starship.toml (shell prompt config), ripgrep — ripgreprc (search config). TOML is preferred for configs because it's human-readable, has a strict spec, and supports typed values (integers, floats, booleans, dates, arrays, tables).
How does TOML handle dates and times?
TOML has first-class date/time types — unlike JSON (strings only) or YAML (requires special tags). TOML date types: Offset Date-Time: 2026-07-26T12:00:00Z. Local Date-Time: 2026-07-26T12:00:00. Local Date: 2026-07-26. Local Time: 12:00:00. These parse to datetime objects in Rust, Python, and other languages without needing format strings. This makes TOML ideal for configs with timestamps, schedules, and deadlines.
What is the difference between TOML tables and arrays of tables?
A table ([table]) is like a JSON object. An array of tables ([[tables]]) creates an array of objects, with each [[tables]] header adding a new element. Example: [[servers]] / name = 'alpha' / ip = '10.0.0.1' / [[servers]] / name = 'beta' / ip = '10.0.0.2' — this creates servers = [{name:'alpha', ip:'...'}, {name:'beta', ip:'...'}]. The double bracket syntax is unique to TOML and handles repeated config sections elegantly.
What is pyproject.toml and what should I put in it?
pyproject.toml is Python's modern package configuration file (PEP 518, 517, 621). It replaces setup.py, setup.cfg, and requirements.txt for package publishing. Sections: [build-system] (the build tool: setuptools, poetry, hatch, flit), [project] (name, version, description, requires-python, dependencies), [project.optional-dependencies] (dev, test extras), [tool.pytest.ini_options], [tool.ruff], [tool.black], [tool.mypy]. Modern Python projects use pyproject.toml as the single configuration file for all tooling.
Can TOML have comments?
Yes — TOML supports hash (#) line comments. A comment starts with # and extends to the end of the line. Example: # This is a comment / port = 8080 # default HTTP port. TOML does not support block comments (unlike C-style /* */). Comments are preserved by some TOML libraries (like toml-rs in Rust) and stripped by others. This is one of TOML's advantages over JSON (which has no comment syntax) and YAML (where comment handling varies).