RazorFormatter
Input
Output
@page "/dashboard" @using MyApp.Components @inject IState State <PageTitle>Dashboard</PageTitle> <div class="grid"> <EditForm Model="@model" OnValidSubmit="Save"> <InputText @bind-Value="model.Name" /> <button type="submit">Save</button> </EditForm> @if (items.Count == 0) { <p class="empty">Nothing here yet.</p> } else { <ul class="list"> @foreach (var item in items) { <li>@item.Title</li> } </ul> } </div> @code { private Model model = new(); private List<Item> items = new(); }

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. Once the page has loaded it keeps working offline, so you can bookmark it and come back any time.

Features

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 v5.0 · Free to use