TOML Formatter
Formatters & BeautifiersFormat TOML config files — Cargo.toml, pyproject.toml, Hugo configs. Free, private — all processing in your browser.
The TOML Formatter beautifies TOML files (Tom's Obvious, Minimal Language) used for configuration in Rust (Cargo.toml), Python (pyproject.toml for Poetry, hatch, pip), Hugo (config.toml), netlify.toml, dbt profiles, and many other modern tools. TOML is a simpler alternative to YAML — no significant whitespace, explicit sections, clear syntax. This formatter normalizes section ordering (optional), aligns key-value pairs, preserves comments, and validates TOML 1.0 syntax.
TOML (v1.0 stabilized 2021) has gained adoption as the preferred config format for modern tooling. Rust Cargo uses TOML. Python PEP 621 made pyproject.toml the standard for Python package metadata. Hugo, netlify, and many new tools default to TOML instead of YAML (easier to get right — no indentation pitfalls). This formatter handles all TOML syntax: tables, arrays, inline tables, arrays of tables, dates, strings with escapes, multiline strings.
TOML Formatter — key features
TOML 1.0 support
All v1.0 syntax: strings (basic, literal, multi-line), numbers (hex, octal, binary), dates, arrays, tables, inline tables, arrays of tables.
Section organization
Detects tables and sub-tables. Optional: sort sections alphabetically.
Alignment
Optional: align `=` in consecutive key-value pairs for readability.
Preserves comments
# comments kept in original positions — important for documented configs.
Syntax validation
Parses TOML to check well-formedness. Reports errors with line numbers.
Consistent string style
Normalizes quotes (single to double where safe). Multi-line strings preserved.
Array formatting
Short arrays on one line. Long arrays broken onto multiple lines.
100% client-side
Your config (possibly with secrets, internal URLs) stays in browser.
How to use the TOML Formatter
- 1
Paste TOML
Cargo.toml, pyproject.toml, Hugo config, any TOML file.
- 2
Configure options
Align =? Sort sections? Short vs long arrays? Defaults work for most cases.
- 3
Click Format
Cleanly formatted TOML with preserved comments.
- 4
Copy or download
Apply to your project. Cargo.toml is ready for cargo build.
Common use cases for the TOML Formatter
Rust
- →Cargo.toml formatting: Rust package manifest. Format dependencies, features, targets.
- →Cargo.lock inspection: Lockfile in TOML format (generated, do not manually edit).
Python
- →pyproject.toml: PEP 621 package metadata. Standard for all modern Python packaging (Poetry, Hatch, pip).
- →Poetry configs: Poetry-specific extensions in pyproject.toml — tool.poetry sections.
- →Black, Ruff, mypy configs: Tool configuration in [tool.*] sections of pyproject.toml.
Static sites
- →Hugo config.toml: Hugo static site generator — TOML is preferred format.
- →Netlify.toml: Netlify deployment config — build settings, redirects, functions.
- →Zola config: Another static site generator using TOML.
Other tools
- →dbt profiles: Data transformation tool uses TOML for profiles.
- →Gleam / Elixir / Go tools: Various language tools adopting TOML.
- →Custom app configs: Many custom tools use TOML for human-editable configs.
TOML Formatter — examples
Cargo.toml
Rust package manifest.
[package]
name="my-crate"
version="0.1.0"
[dependencies]
serde="1.0"
tokio={version="1",features=["full"]}[package]
name = "my-crate"
version = "0.1.0"
[dependencies]
serde = "1.0"
tokio = { version = "1", features = ["full"] }pyproject.toml
Python package config.
[project] name="my-pkg" version="0.1.0" dependencies=["requests>=2.0","click>=8.0"]
[project]
name = "my-pkg"
version = "0.1.0"
dependencies = [
"requests>=2.0",
"click>=8.0",
]Array of tables
Multiple servers.
[[servers]] name="web-1" ip="10.0.0.1" [[servers]] name="web-2" ip="10.0.0.2"
[[servers]] name = "web-1" ip = "10.0.0.1" [[servers]] name = "web-2" ip = "10.0.0.2"
Multi-line string
Description with newlines.
description=""" A multi-line description. """
description = """ A multi-line description. """
Nested tables
Subsections.
[server.ssl] cert="/path/cert" key="/path/key" [server.log] level="info"
[server.ssl] cert = "/path/cert" key = "/path/key" [server.log] level = "info"
Technical details
TOML v1.0 (Tom's Obvious, Minimal Language) — specification by Tom Preston-Werner (GitHub co-founder).
Syntax:
Key-value pairs:
``toml``
name = "Alice"
age = 30
active = true
Strings:
- Basic: name = "Alice" (escape sequences supported)
- Literal: path = 'C:\Users\' (no escape, single quotes)
- Multi-line basic: description = """multi line with \n escapes"""
- Multi-line literal: regex = ''multi line raw''
Numbers:
- Integer: 42, -1000, 0xff (hex), 0o755 (octal), 0b1010 (binary)
- Float: 3.14, 1e10, inf, nan
- Underscores for readability: 1_000_000
Booleans: true, false (lowercase only)
Dates:
- Offset date-time: 2026-05-05T10:30:00Z
- Local date-time: 2026-05-05T10:30:00
- Local date: 2026-05-05
- Local time: 10:30:00
Arrays:
``toml``
tags = ["admin", "user"]
numbers = [1, 2, 3]
mixed = [1, "two", 3.0]
Tables (sections):
```toml
[server]
host = "localhost"
port = 8080
[database]
url = "postgres://..."
```
Nested tables:
``toml``
[server.ssl]
cert = "/path/to/cert"
key = "/path/to/key"
Inline tables (on one line):
``toml``
point = { x = 1, y = 2 }
Arrays of tables:
```toml
[[servers]]
name = "server-1"
ip = "10.0.0.1"
[[servers]]
name = "server-2"
ip = "10.0.0.2"
```
Dotted keys:
``toml``
apple.type = "fruit"
apple.color = "red"
Equivalent to:
``toml``
[apple]
type = "fruit"
color = "red"
Common TOML files:
Cargo.toml (Rust):
```toml
[package]
name = "my-app"
version = "0.1.0"
authors = ["Alice <alice@example.com>"]
[dependencies]
serde = "1.0"
tokio = { version = "1", features = ["full"] }
[[bin]]
name = "main"
path = "src/main.rs"
```
pyproject.toml (Python, PEP 621):
```toml
[project]
name = "my-package"
version = "0.1.0"
description = "A cool package"
authors = [{ name = "Alice", email = "alice@example.com" }]
dependencies = ["requests >=2.0"]
[build-system]
requires = ["setuptools >=61.0"]
build-backend = "setuptools.build_meta"
```
Formatter behavior:
- Normalizes spacing around = (one space each side).
- Aligns values in sections (optional).
- Preserves order within sections.
- Normalizes string quoting (converts single to double if no special chars).
- Keeps comments (# comments) in their position.
- Detects syntax errors.
Validation:
TOML is strict. Parser errors usually indicate:
- Missing quotes around strings.
- Using = after section headers (invalid).
- Inline tables with extra whitespace.
- Mixed array element types (disallowed in arrays).
Common problems and solutions
⚠Mixed array types
TOML arrays can only contain one type. [1, "two"] is invalid. Fix: use same type throughout, or use inline tables.
⚠Extra whitespace in inline tables
Inline tables must be on one line without significant whitespace. `{ x = 1, y = 2 }` OK; `{ x = 1 }` is not.
⚠Dates with wrong format
Dates must be ISO 8601: 2026-05-05 (date), 2026-05-05T10:30:00Z (with time). Other formats are strings, not dates.
⚠Comments inside arrays
TOML allows comments but placement matters. Inside multi-line arrays, each comment must be on its own line between elements.
⚠Dotted keys vs nested tables
apple.type = fruit and [apple] type = fruit mean same thing. Mixing them can confuse. Pick one style per section.
⚠Escape sequences in literal strings
Literal strings '... do not interpret escape sequences. Basic strings "... do. Pick based on content.
⚠Section redefinition
Cannot redefine the same table twice. [server] ... [server] is invalid. Use arrays of tables if you need multiple.
⚠Trailing commas in inline tables
TOML does not allow trailing commas in inline tables (unlike JavaScript). {x = 1,} is invalid.
TOML Formatter — comparisons and alternatives
TOML vs YAML: TOML is simpler — no significant whitespace, explicit sections. YAML is more feature-rich but has quirks (Norway problem, type coercion). TOML is growing for configs; YAML still dominates in K8s/CI.
TOML vs JSON: TOML supports comments (JSON does not). TOML has date type (JSON does not). TOML is more human-readable. JSON is more machine-parseable. Config vs API.
TOML vs INI: INI is older, simpler, less structured. TOML is inspired by INI but adds nested tables, arrays, dates, multiple types. TOML is INI's modern successor.
Cargo.toml vs package.json: Both manifest files. Cargo uses TOML; npm uses JSON. Both accomplish same goal (dependencies, metadata). TOML allows comments, JSON does not.
pyproject.toml adoption: PEP 621 (2020) standardized pyproject.toml for Python package metadata. Replaces old setup.py and setup.cfg. Unified format for all Python tools.
TOML 1.0 vs 0.5: 1.0 (2021) is stable. Earlier versions (0.5, 0.4) had different rules. This formatter uses 1.0 syntax.
Frequently asked questions about the TOML Formatter
▶What is TOML?
TOML (Tom's Obvious, Minimal Language) is a configuration format designed to be easy to read and parse. Used by Rust Cargo, Python Poetry/Hatch, Hugo, Netlify, and many modern tools. Simpler than YAML, more readable than JSON.
▶When should I use TOML vs YAML vs JSON?
TOML for config files meant for humans to edit — Cargo.toml, pyproject.toml. YAML for complex configs (K8s, CI) where you need features like anchors. JSON for data interchange (APIs). All three have their place.
▶Is my TOML safe here?
Yes. Formatting in your browser. No upload.
▶Does it validate my TOML?
Yes, syntax-level. Checks well-formedness. Reports errors with line numbers. For semantic validation (does your Cargo.toml specify valid fields?), use tool-specific validators.
▶What version of TOML is supported?
TOML 1.0 (current stable, released 2021). All 1.0 syntax supported.
▶Can I format Cargo.toml?
Yes. Cargo.toml is standard TOML. Format for readability or to normalize team style. Cargo itself does not modify your Cargo.toml after manual edits.
▶Can it format pyproject.toml?
Yes. Python PEP 621 pyproject.toml is TOML. Format for cleaner commits. Poetry-specific or Hatch-specific sections preserved.
▶What about comments?
Comments (# ...) preserved in their original positions — essential for documented configs.
▶Does it sort sections?
Optional. By default, section order preserved. Enable sorting to alphabetize (may conflict with intentional grouping).
▶Can it convert TOML to JSON or YAML?
Not directly. For conversion, use specialized tools. Most TOML libraries (tomli in Python, toml-edit in Rust) can output as JSON.
Additional resources
- TOML v1.0 Specification — Official TOML specification.
- Cargo.toml Reference — Rust Cargo manifest format.
- PEP 621 — pyproject.toml — Python package metadata standard.
- Hugo Configuration — Hugo static site TOML config.
- Netlify.toml Reference — Netlify build/deploy config.
Related tools
All Formatters & BeautifiersGit Commit Message Generator
Create conventional commit messages — feat, fix, docs, with scope and breaking changes
.gitignore Generator
Create .gitignore files for 100+ languages, OS, IDEs — combinable templates
HTML Formatter
Format, indent, and beautify HTML, XHTML, and HTML5 markup
JSON Formatter
Format, validate, and beautify JSON instantly in your browser
JSON to YAML Converter
Convert JSON to YAML or YAML to JSON — preserves structure, nested objects
Python Formatter
Format Python code with Black-compatible style — PEP 8 compliant, consistent
Learn more
Explore more tools
200+ free tools that run in your browser.
Browse all tools →