Text UtilitiesText FormattersFree Tool

Rust Formatter

Apply basic bracket-based indentation to Rust code — not a real parser like rustfmt, so complex code may not indent perfectly.

How to Use Rust Formatter
  1. 1Paste your Rust code
  2. 2Click Convert
  3. 3Copy the re-indented output — use `cargo fmt` for real Rust projects
Frequently Asked Questions

It counts opening ({, [, () and closing (}, ], )) brackets per line and adjusts indentation depth accordingly — a simple heuristic, not Rust's real parser.

No — lifetime annotations and macro_rules! syntax aren't specially handled; only curly/square/round brackets affect indentation.

`rustfmt` (or `cargo fmt`) — the official Rust formatter, bundled with the standard toolchain.

No — the indentation pass runs entirely in your browser.

Related Tools

Related Articles

More from Text Utilities