# TOML Formatter > Format messy TOML with 2 or 4 spaces, or convert it to JSON. The validator checks TOML v1.0.0 and reports the exact line and column of each error. Free, in your browser, nothing is uploaded. ## What it does - Formats TOML with 2 or 4 spaces, or converts it to JSON. - Validates against TOML v1.0.0: duplicate keys, unclosed strings and arrays, tab indentation, redefined tables, trailing commas in inline tables. - Reports the exact line and column of the first error. - Shows a tag count (tables and keys) for valid files. - Loads Cargo.toml and pyproject.toml samples. Opens .toml files up to 2 MB. - Formats live while typing for inputs under 300,000 characters; longer inputs wait for the Format button. - Limits: 2,000,000 characters of input. ## What formatting changes - Spacing, line breaks and indentation only: `key = value` with one space on each side, one blank line before each table header, long arrays one item per line. - Dotted keys are expanded into table headers: `a.b.c = 1` becomes `[a.b]` with `c = 1`. - Literal strings are re-printed as basic strings. Multi-line strings stay multi-line. - Comments are not kept: the formatter prints from the parsed data, and comments are not data. - Numbers and dates are printed exactly as written. ## Errors it catches - Duplicate key: the same key twice in one table. - Table already defined: two headers for one table, or a header after a dotted key created the table. - Tabs used for indentation, which TOML forbids. - Unterminated basic or literal strings; unclosed arrays and inline tables. - Trailing comma in an inline table (arrays allow one, inline tables do not). - Invalid numbers, dates and times, including a February 30 or a 25:00 hour. ## Code snippets Check TOML from the command line with Taplo: ```bash taplo fmt Cargo.toml ``` Check TOML with Python 3.11 or later (standard library only): ```python import tomllib with open("pyproject.toml", "rb") as f: tomllib.load(f) print("valid TOML") ``` ## Sources - TOML project, TOML v1.0.0: https://toml.io/en/v1.0.0 - The Cargo Book, The Manifest Format: https://doc.rust-lang.org/cargo/reference/manifest.html - Python documentation, tomllib: https://docs.python.org/3/library/tomllib.html