C++ Beautifier

Format modern C++ with clang-format presets.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

C++ Beautifier – Format C++ Code Online

The C++ beautifier formats C++ with clang-format, the industry-standard C++ formatter used by LLVM, Google, Chromium, and most modern C++ code bases. It runs in your browser as WebAssembly — no installation, no upload.

Modern C++ support

  • Templates, template specializations, and concepts with requires clauses.
  • Lambdas with captures, auto return types, and trailing return types.
  • Namespaces, classes with access specifiers, constructors with initializer lists.
  • Range-based for loops, structured bindings, and constexpr/consteval functions.
  • Operator overloads, smart pointers, and the standard library.

Style presets

clang-format ships with the coding styles of well-known projects:

  • LLVM – 2-space indentation in LLVM itself (configurable here), braces on the same line.
  • Google – Google's style guide; the usual choice for Java and many C++ projects.
  • Chromium and Mozilla – the browsers' variants of the Google and LLVM styles.
  • WebKit – 4-space indentation, function braces on their own line.
  • Microsoft – Allman braces (every brace on its own line), common in C# and Windows code.
  • GNU – the GNU coding standards with half-indented braces.

You can override the indentation (2 or 4 spaces or tabs) and the column limit (80, 100, 120, or no limit) on top of any preset.

The Google preset with 2-space indentation is selected by default for C++, since it is the most widely used C++ style outside of LLVM itself.

How to use it

Paste your code or click Sample to load a compressed template class with a lambda. Choose the style, indentation, and column limit; the formatted C++ appears instantly and can be copied or downloaded.

When formatting helps most

Use it to clean up code pasted from competitive programming sites, Stack Overflow, or chat messages, to review code without a configured IDE, or to see how a different style preset would look before adding a .clang-format file to your repository.

Notes

clang-format does not compile your code. It does not reorder includes unless configured to, and it never changes tokens — only whitespace and line breaks.

Format plain C with the C Beautifier, Java with the Java Beautifier, and JSON data with the JSON Beautifier.

Frequently Asked Questions

This page offers the standard presets with indentation and column limit overrides. For a complete custom configuration, run clang-format locally with your .clang-format file.

Yes. Concepts, requires clauses, modules syntax, designated initializers, and other modern features are understood by clang-format.

Some presets, such as LLVM and Google, allow short functions on a single line. Choose WebKit or Microsoft if you always want braces on separate lines.