Formateur de code C / C++
Guide
Formateur de code C / C++
Format your C and C++ code instantly using industry-standard style presets. Paste messy or inconsistently formatted code and get clean, properly structured output that matches LLVM, Google, Chromium, Mozilla, WebKit, or Microsoft style guidelines — with full control over indentation, brace wrapping, and pointer alignment.
Comment utiliser
Paste your C or C++ code into the input area. Select a style preset to auto-configure the formatting options, or manually adjust indent width, brace wrapping style, and pointer alignment to match your project conventions. The formatted code appears instantly in the output panel — copy it with one click.
Caractéristiques
- Style Presets – One-click formatting with LLVM, Google, Chromium, Mozilla, WebKit, and Microsoft style configurations that match real clang-format defaults.
- C and C++ Support – Handles both C and C++ syntax including classes, templates, namespaces, and preprocessor directives.
- Brace Wrapping Styles – Choose between Attach (K&R), Allman (next line), Stroustrup, or GNU brace placement for functions, conditionals, and loops.
- Pointer Alignment – Configure whether pointer and reference operators bind left (
int* p), right (int *p), or middle (int * p). - Indentation configurable – Set indent width (2, 4, or 8) and choose between spaces or tabs.
- Mise en forme en temps réel – Output updates instantly as you type or change any formatting option.
Quand utiliser cet outil
Use this tool when cleaning up code snippets for code review, standardizing formatting before committing to a shared repository, or converting between style guides when moving code between projects. It’s especially useful for quickly reformatting code examples for documentation, blog posts, or Stack Overflow answers.
FAQ
-
What is clang-format and why do C++ projects use it?
clang-format is an open-source tool from the LLVM project that automatically formats C, C++, Objective-C, and other languages according to configurable style rules. Projects use it to enforce consistent code style across teams — it eliminates formatting debates during code review and ensures every contributor's code looks the same regardless of their editor or personal preferences.
-
What is the difference between Allman and K&R brace style?
K&R (Kernighan and Ritchie) style places the opening brace on the same line as the control statement: if (x) {. Allman style (named after Eric Allman) places it on the next line, aligned with the control statement. K&R is more compact and is used by LLVM, Google, and Chromium. Allman is used by Microsoft's style guide and is popular in C# and some C codebases because the aligned braces make block boundaries visually obvious.
-
Should the pointer asterisk go with the type or the variable name?
This is one of C/C++'s oldest style debates. Left alignment (int* p) treats the pointer as part of the type, which is the C++ convention used by Google and LLVM. Right alignment (int *p) reflects how C actually parses declarations — in 'int *p, q', only p is a pointer. Both are valid; the important thing is consistency within a project. Most modern C++ style guides prefer left alignment.
-
What column limit should I use for C++ code?
The most common limits are 80 and 120 characters. The 80-column tradition dates back to punch cards and terminal widths, and is still used by LLVM, Google, and the Linux kernel. 120 columns is increasingly popular for modern development where wider monitors are standard. Some projects like WebKit use no hard limit. Choose based on your team's displays and whether code will be viewed in side-by-side diffs.
Installez nos extensions
Ajoutez des outils IO à votre navigateur préféré pour un accès instantané et une recherche plus rapide
恵 Le Tableau de Bord Est Arrivé !
Tableau de Bord est une façon amusante de suivre vos jeux, toutes les données sont stockées dans votre navigateur. D'autres fonctionnalités arrivent bientôt !
Outils essentiels
Tout voir Nouveautés
Tout voirMise à jour: Notre dernier outil was added on Mar 23, 2026
