C# Formatter

Format C# classes, methods, properties, records, and pasted snippets with consistent indentation, spacing, braces, and line wrapping without renaming symbols or changing code behavior.

C# formatting controls

Start from LLVM, Google, Chromium, Mozilla, WebKit, or GNU style. You can use an indent width from 1 to 16 and a column limit from 0 to 1000; setting the column limit to 0 disables wrapping. Load a .cs file or paste code, then copy or save the result.

Code formatter FAQ

How do I format code on this page?

Paste code into the left editor or load a file, choose the options you need, and select Format. Review the result on the right, then copy or save it.

Why might the formatter report an error?

The input must match the selected language or syntax. Check incomplete statements, unmatched brackets or quotes, and a dialect or mode that does not match the input, then format again.

How does a code formatter work?

A code formatter reads language-aware tokens and nested structures, then rewrites indentation, spacing, and line breaks according to a consistent rule set. It does not compile or run the program, so formatting is not a correctness or security check.

Which settings are recommended for this language?

Most .NET projects use 4 spaces; 100 or 120 columns is a practical starting point, but an existing .editorconfig or repository convention should win. Choose LLVM, Google, Chromium, Mozilla, WebKit, or GNU style, then set the indent width and column limit for C# code.