TOML Formatter and Beautifier

Paste a messy TOML file and get it back with even spacing around keys, values, arrays, and inline tables. It also points out syntax errors. Everything runs in your browser, so your config stays on your device.

Indent

Format uses dprint's TOML formatter. The options apply to Format.

Result

What is TOML?

TOML is a config file format made of key = value pairs grouped into [tables]. It is used by Cargo.toml in Rust, pyproject.toml in Python, and tools like Hugo and Netlify. Because TOML files are often edited by hand, spacing drifts over time. A TOML formatter puts the spacing back in order around equals signs, arrays, and inline tables, and checks that the file still parses, without changing any values.

Why use our TOML formatter

  • ·Free. No signup, no paywall, no limits.
  • ·Runs in your browser. The formatter runs locally as WebAssembly, so your config is never uploaded.
  • ·Keeps your comments. Comments and the order of your tables are left in place.
  • ·Finds errors. Syntax errors are shown with their line and column.
  • ·Cargo.toml support. Optional rules sort dependency lists the way Rust projects do.

TOML formatter options

Format

Puts one space on each side of every equals sign and cleans up the spacing inside arrays and inline tables. Comments and the order of your tables stay as they are.

Beforename="demo" ports=[8000,8001] serde={version="1"}Aftername = "demo" ports = [8000, 8001] serde = { version = "1" }

Indent

Choose 2 or 4 spaces for the items of an array that spans several lines.

Beforeports=[ 8000, 8001]Afterports = [ 8000, 8001, ]

Sort keys

Sorts the keys inside each table alphabetically. The tables themselves stay in the order you wrote them.

Beforezeta = 1 alpha = 2Afteralpha = 2 zeta = 1

Cargo.toml rules

Applies the conventions Rust projects use for Cargo.toml, such as sorting dependency lists and putting name before version in the package table.

Before[dependencies] tokio = "1" anyhow = "1"After[dependencies] anyhow = "1" tokio = "1"

When to format TOML

A TOML formatter helps whenever a config file has been edited by hand or copied from somewhere else. These are the cases that come up most:

  • ·Rust projects. Clean up Cargo.toml and sort its dependencies before you commit.
  • ·Python projects. Fix the spacing in pyproject.toml after adding tool settings by hand.
  • ·Checking a config. Find the exact line of a syntax error before a tool refuses to start.
  • ·Static sites and hosting. Clean up hugo.toml, netlify.toml, and similar settings files.

Learn more about TOML

These references explain the TOML format and the files that use it most:

Formatting TOML in your own project

This tool formats TOML with dprint's TOML plugin. To format files in your repository, you can use dprint or Taplo, another popular TOML tool:

ToUse
Set up dprintnpx dprint init, then add the TOML plugin
Format with dprintnpx dprint fmt
Format with Taplotaplo fmt Cargo.toml
Format on saveThe Even Better TOML extension for VS Code formats with Taplo

Both tools only change layout. Keys, values, and comments stay the same, so it is safe to format a Cargo.toml or pyproject.toml before committing.

If you work with other config formats, these tools run the same way, right in your browser:

Frequently asked questions

What is TOML?
TOML (Tom's Obvious Minimal Language) is a config file format built to be easy for people to read. It uses key = value pairs grouped into [tables]. Rust uses it for Cargo.toml, Python for pyproject.toml, and many other tools like Hugo, Netlify, and Poetry use it for settings.
How do I format a TOML file?
Paste your TOML into the input box, pick your options, then click Format. The clean version appears below. Click the copy button to copy it, or download it as a .toml file.
Can this tool validate TOML?
Yes. If the TOML cannot be parsed, the tool does not format it and instead shows the error with its line and column, so you can find the problem quickly.
Does formatting change my settings?
No. Formatting only changes spaces, line breaks, and trailing commas, so every key keeps the same value. Sorting keys changes the order they are written in, but TOML does not care about key order inside a table, so the meaning stays the same.
Can I format Cargo.toml and pyproject.toml?
Yes. Both are normal TOML files. For Cargo.toml, turn on Cargo.toml rules to also sort your dependency lists the way many Rust projects do.
Is my TOML kept private?
Yes. The formatter is compiled to WebAssembly and runs entirely in your browser. Your file is never uploaded to a server or saved anywhere, so it is safe to paste configs that contain internal hostnames or paths. Once the page has loaded you can even use it offline.