Rust beautifier - fix Rust indentation in your browser
Rust is a language whose full formatters (like Black for Python, gofmt for Go) do not run in a browser - they would require Pyodide / WASM / JVM weighing tens of megabytes. For Rust we therefore do VS-Code-style cosmetic formatting - the Cosmetic-only mode.
What it actually changes: tabs ↔ spaces conversion, indent-width normalisation (pick: tab / 2 / 4 spaces), trim trailing whitespace, line-ending normalisation (CRLF → LF). It does not change code structure - that would be a job for a real formatter, which for Rust you need to run locally.
Same thing Format Document in VS Code does for Rust without a registered formatter extension. Safe - will not break your code because it does not touch syntactic constructs.
After formatting you get a syntax-highlighted preview (powered by Shiki, the same TextMate grammars VS Code uses).
How to use it
- Pick a mode (Gentle / Aggressive / Cosmetic-only) or keep the default.
- Paste your code into the left panel, or use "Upload file".
- Tune settings (gear icon): indent, width, quotes, semicolons.
- Click Format - first click takes a moment (libraries lazy-load).
- On the right you get the output with syntax highlighting - copy, download, or open in new tab.
When this is useful
Five situations where this is useful:
- Tabs-to-spaces conversion (or vice-versa). Your `.editorconfig` says 2 spaces, a colleague's code has tabs.
- CRLF → LF normalisation. A file from Windows opened on Linux - git complains.
- Trim trailing whitespace. Spaces at end of lines (the classic copy from PDF / email).
- Syntax-highlighted preview. You pasted Rust into an editor without colouring - beautify, get a preview.
- Reformat imported code. You copied a snippet from Stack Overflow / GitHub and the indentation drifted.