Skip to content

C/C++ Formatter

Embed

Paste this where you want C/C++ Formatter on your site. Adjust the height to fit.

<iframe src="https://www.browserutils.dev/embed/cpp-formatter/" width="100%" height="500" frameborder="0" loading="lazy" title="C/C++ Formatter"></iframe>
<p style="font-size:12px;margin:4px 0 0"><a href="https://www.browserutils.dev/tools/cpp-formatter/">C/C++ Formatter</a> by BrowserUtils</p>

Beautify and format C and C++ code.Runs in this tab.

Next step

About C/C++ Formatter

Free online C/C++ code formatter. Format C and C++ source code with configurable indentation, brace style, and preprocessor handling. It runs in your browser. Nothing is sent to a server.

Questions

What brace styles are supported?
Choose between K&R style (same-line braces) or Allman style (new-line braces). Preprocessor directives are kept at column 0 regardless of indentation level.
Does it handle preprocessor directives?
Yes, #include, #define, #ifdef, and other preprocessor directives are recognized and kept unindented at the start of the line, following C/C++ conventions.
Can I format C++ templates and lambda expressions?
Yes, the formatter handles C++ templates, lambda expressions, range-based for loops, auto declarations, and other modern C++ features.
Does the C/C++ formatter work with both C and C++ code?
Yes, the formatter supports both C and C++ syntax. C-specific code and C++ features like classes, namespaces, and operator overloads are all formatted correctly.

More in Formatters & Beautifiers

All 26 formatters & beautifiers