C# Formatter, Viewer and Minifier
FV-43Paste C# and read it clean: Format lays it out with clang-format, Minify strips comments and extra spaces. Both run in your browser.
Runs in your browser. Nothing is uploaded.
C# code
Result
How to use it
- Paste your C#, or open a .cs file or drop it on the input box.
- Pick a base style, indent and line width.
- Press Format to lay the code out, or Minify to shrink it.
- Copy the result or download it as a .cs file.
Format
Format runs clang-format with its C# support. The default Microsoft style places braces on their own lines, which is the layout most C# teams expect. Other presets such as Google or LLVM keep braces on the same line. Your indent and column limit override the preset. It lays out text only, so it does not check that the code compiles, and your .editorconfig rules are not read.
Minify
Minify removes comments and extra whitespace and joins lines, keeping the tokens the compiler sees. Regular, verbatim and interpolated strings and char literals are copied exactly. Lines that start with # such as #region and #if stay on their own lines, because C# needs them there. Nothing is renamed, so a minified file is only smaller, not hidden.
Errors and limits
Format never reports syntax problems. Minify reports an unclosed string, character or comment with its line and column. Raw string literals with three quotes are handled, but very unusual preprocessor use may keep more line breaks than strictly needed. Even so, run your test suite on minified output before relying on it.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
String is never closed (missing ") (line 1, column 9). | A string literal was opened with a quote that has no matching closing quote. | Add the closing quote at the position shown, or escape a quote inside the string. |
Questions people ask
How do I format C# code online?
Paste the code into the box and press Format. The Microsoft style puts braces on new lines and indents by your chosen width. Copy the result or download it as a .cs file.
What does Minify do to C#?
It removes comments and unneeded spaces and line breaks, and keeps strings and preprocessor lines intact. The program behaves the same; it is only shorter.
Will Minify rename my variables?
No. Identifiers are left alone. The saving comes from whitespace and comments only. Identifiers, namespaces and strings stay exactly as written. The saving comes from whitespace and comments only, so a minified file is smaller but not hidden or obfuscated.
Does it check my C# for errors?
Format does not. It lays out whatever you paste. Minify only reports unclosed strings, characters or comments. Compile the code to find real errors. Format does not report syntax problems. Minify only reports an unclosed string, character or comment. Compile the code to find real errors.
Can I get Allman or K&R braces?
Pick a base style. Microsoft uses Allman style braces on their own lines, while Google, LLVM and Mozilla put them on the same line. The setting applies to the whole file.
About this tool
Format runs clang-format for C#, compiled to WebAssembly in your browser. The Microsoft style puts braces on their own lines; the other styles are clang-format presets and may not match your .editorconfig. It formats text and does not compile it, so syntax errors are not reported. Minify removes comments and extra whitespace, keeps strings, verbatim and interpolated strings, and keeps preprocessor lines such as #region on their own lines. It renames nothing. Minified code is for size checks, not for hiding code.