# TOML Formatter

Format and beautify TOML. Note: comments are lost and key order may change (@iarna/toml limitation)

> Canonical page: https://elysiatools.com/en/tools/toml-formatter

- **Category:** Format Conversion

- **Keywords:** toml, formatter, beautify, pretty print, toml formatter, toml beautifier

## Overview

The TOML Formatter is a utility designed to clean up, beautify, or minify your TOML configuration files. It parses your input and outputs structured, readable TOML, though please note that comments are removed and the order of keys may change during processing.

## Inputs

- **TOML Input** (textarea): Enter your TOML here. Note: comments will be lost and key order may change after formatting.
- **Indent Size** (number): TOML uses 2 spaces (option kept for UI consistency)
- **Mode** (select)

## When to use

- When you need to clean up messy or poorly indented TOML configuration files for projects like Rust or Python.
- When you want to minify TOML data to reduce file size for storage or transmission.
- When validating the syntax of a TOML snippet to ensure it parses correctly without syntax errors.

## How it works

- Paste your raw TOML configuration text into the TOML Input area.
- Select your formatting mode, choosing either Beautify to format with indentation or Minify to compress the output.
- Adjust the indentation size if needed, then run the formatter to generate the clean TOML output.

## Use cases

- Beautifying a cluttered Cargo.toml file for a Rust project to improve readability.
- Minifying pyproject.toml configurations to save space in automated deployment pipelines.
- Checking and fixing indentation inconsistencies in Hugo static site generator configuration files.

## Frequently asked questions

### Why did my comments disappear after formatting?

The underlying parser does not preserve comments during the parsing and serialization process.

### Why did the order of my keys change?

The formatter parses TOML into an internal data structure where key order is not guaranteed to remain identical to the input.

### Can I minify my TOML file using this tool?

Yes, you can switch the mode option from Beautify to Minify to compress your TOML data.

### What indentation sizes are supported?

You can configure the indentation size from 0 to 8 spaces, with 2 spaces being the default standard.

### Does this tool validate TOML syntax?

Yes, if the input TOML contains syntax errors, the formatter will fail to parse it and will display an error message.

## Related tools

- [JSON Formatter](https://elysiatools.com/en/tools/json-formatter): Format and validate JSON data
- [XML Formatter](https://elysiatools.com/en/tools/xml-formatter): Format, beautify and minify XML with configurable indent. Preserves comments and CDATA
- [YAML Formatter](https://elysiatools.com/en/tools/yaml-formatter): Format and beautify YAML. Note: comments are lost (js-yaml limitation)
- [CSS Beautifier](https://elysiatools.com/en/tools/css-beautifier): Format and beautify minified or messy CSS code into readable, well-indented stylesheets
- [VBA Code Formatter](https://elysiatools.com/en/tools/vba-formatter): Format and beautify VBA code for better readability
- [SQL Query Formatter & Minifier](https://elysiatools.com/en/tools/sql-query-formatter): Beautify or minify SQL with full control over dialect (PostgreSQL, MySQL, SQLite, SQL Server/T-SQL, BigQuery, Snowflake, and more), keyword / identifier / function casing, indent style (standard, tabular-left, tabular-right), and spacing between statements. Produces a syntax-highlighted, copy-ready result with live size and statement stats.
- [Code Formatter](https://elysiatools.com/en/tools/code-formatter): Format code in various languages
- [JavaScript Deobfuscator](https://elysiatools.com/en/tools/javascript-deobfuscator): Deobfuscate and analyze obfuscated JavaScript code to improve readability and understanding

## Samples

- [TOML Samples](https://elysiatools.com/en/samples/toml-samples): TOML (Tom's Obvious, Minimal Language) format examples from simple to complex structures
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion

## Related content

- [Text Redaction, Highlighting, and Presentation Formatting Tools](https://elysiatools.com/en/hubs/text-format): Compare tools for masking sensitive text, finding PII, normalizing phone numbers, highlighting phrases, centering text, and formatting diffs in one hub.
- [JSON Formatting, Diff, and Normalization Tools](https://elysiatools.com/en/hubs/json-format): Compare JSON formatting, diffing, log review, config comparison, and data-normalization tools in one hub for readable and reviewable JSON workflows.
