Format Razor and Blazor in your browser
Razor Formatter tidies .razor and .cshtml files, re-indenting the mix of HTML, C# and Blazor components and putting the directives in order. Paste your code above, press Format, and copy the result.
Privacy
Your code never leaves your machine. Formatting runs in your browser, inside a Web Worker on your own device, so nothing you paste is uploaded or logged. There are no accounts and no tracking of what you format. After your first visit the page is stored by your browser, so it opens and formats offline too.
Features
- Re-indents markup,
@codeblocks and Razor control flow - Sorts directives into a consistent order, with
Systemnamespaces first - Collapses multi-line
@()expressions and normalises blank lines - Recognises Blazor components through .NET 11, and lets you register your own
- Flags unclosed tags and unmatched braces, with the line and the reason
- Syntax highlighting, indent guides, word wrap and adjustable text size
- Light and dark themes that follow your system, a minimal mode, and resizable panes
Performance
The engine formats around 15,000 lines in under 100 milliseconds, and runs off the main thread so the interface stays responsive while it works. Lines you cannot see yet are left unrendered until you scroll to them, which keeps even large files smooth. Your preferences and your last snippet are kept in the browser between visits.
Support
If a file does not format the way you expect, or there is a feature you would like added, get in touch. A short note with a small example is the quickest thing to act on, and every message is read.
Contact
Email me. Razor Formatter is made by Tahleel Consultancy.
Razor Formatter v6.0 · Free to use