TOML Formatter & Validator

Paste TOML, click Format to canonicalize the layout, or Validate to check syntax against TOML 1.0. Runs in your browser — no upload.

  1. Paste your TOML into the left textarea.
  2. Click Format to round-trip through @iarna/toml and produce canonical layout.
  3. Click Validate to check syntax without modifying the input.
  4. Errors point at the offending line and column.
What does it do?

Parses your TOML with @iarna/toml in TOML 1.0 mode and re-emits it with canonical layout — keys before sub-tables, consistent quoting, integer underscores stripped. The Validate button checks syntax against the spec without changing the input. Comments are dropped during the round-trip (TOML formatters generally cannot preserve them through a parse-and-dump cycle).

Example

Messy TOML input:

[server]
host="localhost"
port=8080

name="myapp"

Formatted output:

name = "myapp"

[server]
host = "localhost"
port = 8080

Common TOML errors and how to fix them

TOML 1.0 has stricter rules than YAML or JSON. The patterns below cover most parser failures.

  • Unquoted strings. `name = Ada` is invalid. Use double quotes: `name = "Ada"`.
  • Re-defining a table. Defining `[a]` twice is an error. Each table header may appear at most once. Merge keys into a single `[a]` block.
  • Top-level keys after a table. Once you write `[section]`, all subsequent keys belong to that section. Keys must come before their first table header. The formatter reorders this for you, but the raw input must already be valid.
  • Datetime without timezone. `d = 2026-04-26T12:00:00` (no Z or offset) is a "local datetime". It parses, but JSON-style consumers may not have a way to represent locality. Use `2026-04-26T12:00:00Z` for UTC.
  • Inline table extension. Inline tables `point = {x=1, y=2}` are closed and self-contained. You cannot later write `point.z = 3`. Use the standard `[point]` block syntax to extend.
  • Triple-quote escape confusion. `"""..."""` (basic multi-line) processes escapes; `\'\'\'...\'\'\'` (literal multi-line) does not. Mixing the two is the most common multi-line string error.
Frequently asked questions

Does Format change my data?

Only the layout — keys are reordered to put primitives before sub-tables (a TOML rule), spacing is normalized, integer underscores are stripped (TOML semantics). Values themselves are unchanged.

Are TOML comments preserved?

No. @iarna/toml drops comments during the parse-and-dump round-trip. If you need comment-preserving formatting, you would need a different library that retains source position information.

Does this validate against TOML 1.0?

Yes. @iarna/toml follows TOML 1.0 — including allowing mixed-type arrays, dotted keys, and revised string rules. Inputs that depend on TOML 0.5-only behavior (homogeneous arrays required) will still parse here, but may break on stricter 0.5 parsers.

How big a TOML file can it handle?

Up to about 30 MB before the textarea slows down. Most config files are well under 1 MB.

Is my TOML uploaded?

No. Everything runs in your browser — your input is parsed and re-serialized by JavaScript on this page and never sent to any server.

Why does the formatter reorder my keys?

TOML 1.0 requires top-level keys (primitives) to appear before any table header within the same scope. The formatter enforces this by sorting primitives ahead of sub-tables. If your original input had a different order, the format step normalizes it.