CalcCafe

C# Formatter

Re-indent C# code consistently based on brace depth. It runs entirely on your device — nothing is uploaded.

Example

Paste C# to normalise its indentation. This is a brace-depth re-indenter, not a full C#-aware reformatter.

How it works

This formatter normalises indentation using brace and bracket depth — a fast, language-agnostic tidy-up.

Good to know

The C# Formatter re-indents pasted C# source by tracking brace and bracket depth, giving every line a consistent indentation level based on how deeply nested it sits. It's aimed at developers who need to quickly tidy up a snippet copied from a chat thread, a code review comment, a log, or a diff where the original whitespace got mangled — without firing up an IDE or running a build.

Reach for it when you want a fast visual cleanup rather than a full reformat. Because it works on depth alone, it's language-agnostic at heart and won't choke on partial code, missing usings, or a single method pulled out of context. That makes it handy for sharing readable examples, sanity-checking that braces actually balance, or normalising indentation before pasting into documentation.

Read the output as a structural map: each opening brace pushes the next lines one level deeper, each closing brace pulls them back. If a block looks indented too far or never returns to the margin, that's a strong hint a brace is unbalanced or missing somewhere above it. The result should be deterministic for the same input, so it's reproducible to share with a teammate.

One caveat — this is a brace-depth re-indenter, not a Roslyn-aware reformatter. It does not understand C# semantics, so it won't reflow long lines, fix spacing around operators, align switch arms, reorder usings, or apply EditorConfig rules. For canonical, compiler-accurate style on a real project, run dotnet format or your IDE's formatter; use this tool for the quick, private, in-browser cleanups where that's overkill.

Frequently asked questions

Is my data uploaded anywhere?
No — everything runs in your browser. Your code never leaves your device, so it's safe for private work and runs offline once loaded.
Is this tool free?
Yes, completely free with no sign-up and no limits.

People also ask

Does the C# Formatter follow EditorConfig or dotnet format rules?
No. It indents purely by brace and bracket depth and ignores .editorconfig, project settings, and Roslyn formatting rules. For style that matches your project's configuration, use dotnet format or your IDE's built-in formatter.
Will it fix unbalanced or missing braces in my C# code?
It won't add or remove braces, but it makes imbalances visible: if indentation keeps drifting deeper or never returns to the left margin, that usually points to a missing or extra brace. You still have to correct the code yourself.
Can it format Razor, .cshtml, or XAML files?
It is designed for C# source and re-indents based on braces and brackets, so mixed markup files like Razor or XAML won't be handled correctly. Use a tool built for those formats instead.
Does it change tabs to spaces or let me set the indent size?
The tool normalises indentation by depth; it does not perform semantic spacing fixes such as operator spacing or line reflow. Check the tool's controls for any indent-width or tab option, and verify the result against your team's preferred style.
Is it safe to paste proprietary or confidential C# code?
The tool runs entirely in your browser and does not upload your code anywhere, so it can be used for private work and even offline once the page has loaded.
What is the difference between this and a C# beautifier or linter?
This is a lightweight re-indenter that only adjusts whitespace by nesting depth. A full beautifier reflows and aligns code using language rules, and a linter flags style or correctness issues without necessarily reformatting them.
How do I format C# without an IDE?
You can paste code into a browser-based re-indenter like this one for a quick whitespace cleanup, or run the command-line tool dotnet format from the .NET SDK for compiler-accurate formatting of a whole project.

Related tools