The only formatter built for Razor
Every other formatter breaks your Blazor code. This one understands it.
Why Razor files are hard to format
Razor files mix three languages in one file: HTML markup, C# logic, and Blazor component syntax. Generic formatters like Prettier treat @if blocks as broken HTML. Visual Studio's built-in formatter doesn't handle multi-line tag attributes with Razor expressions like @(condition ? "value-a" : "value-b"). Razor Formatter was built from scratch to handle exactly these cases.
What it does
Paste any .razor or .cshtml file and get properly indented code in milliseconds. The formatter applies Allman-style braces for C# blocks, correctly indents nested Blazor components like EditForm, AuthorizeView, and InputSelect, sorts your @using and @inject directives by convention, and collapses multi-line Razor expressions. It knows the difference between self-closing components like InputText and container components like CascadingValue.
Built for real Blazor projects
Register your project's custom components so they're formatted correctly. Import your .editorconfig to match your team's indent style. Open multiple files at once with batch formatting. Compare two files with a proper LCS diff algorithm. Run an accessibility check to catch missing alt attributes and unlabelled inputs before they reach code review.
Private by design
Your code is processed entirely in your browser. Nothing is sent to any server, ever. The formatting engine runs in a Web Worker for performance, but it's still local JavaScript. No telemetry, no analytics on code content, no accounts required. Made and hosted in the EU by Tahleel Consultancy.
Fast enough for large files
Virtual scrolling renders only the visible lines, keeping the DOM under 100 nodes even for 30,000-line files. Syntax highlighting is cached per line with pre-compiled regex patterns. The diff engine caps at 8,000 trace steps to prevent memory issues. Smart dirty tracking means the formatter won't re-run if nothing has changed.
Free and open
Razor Formatter is free to use with no limits. No sign-up, no paywall, no ads. Format as many files as you need. Works on any device with a modern browser.
Razor Formatter supports .razor and .cshtml files for ASP.NET Core, Blazor Server, Blazor WebAssembly, and Blazor United (.NET 8+). Compatible with all modern browsers. Made by Tahleel Consultancy.