Format
Rewrites your C with consistent braces, spacing, and indentation using clang-format. Turns cramped or messy code into clean, readable source.
int main(){return 0;}Afterint main() {
return 0;
}Paste cramped or messy C and get it back with consistent braces, spacing, and indentation. The formatter is clang-format, running in your browser, so your code stays on your device.
Format uses clang-format. The style and indent options apply to Format.
C gives you a lot of freedom over spacing and brace placement, so code from different people or tools can look very different. A formatter, also called a beautifier, rewrites the source with one consistent set of rules: braces in the same place, even indentation, and consistent spacing. This tool uses clang-format, a widely used C formatter, and changes only the layout, never what the program does.
Rewrites your C with consistent braces, spacing, and indentation using clang-format. Turns cramped or messy code into clean, readable source.
int main(){return 0;}Afterint main() {
return 0;
}Pick the base style clang-format follows: LLVM, GNU, Google, and more. Each sets brace placement, spacing, and other rules to match a well-known C style.
LLVM, GNU, Google...AfterYour chosen house styleChoose 2 or 4 spaces for each level of nesting, so the formatted C matches the style used in the rest of your project.
2 spaces or 4 spacesAfterYour choice per levelA formatter helps whenever C source is hard to read or needs to match a shared style. These are the cases that come up most:
Once your C is formatted, these references explain the language and the formatter behind this tool:
This tool runs clang-format, the standard formatter for C, compiled to run in your browser. The same styles work on your machine:
| To | Use |
|---|---|
| Format a file in place | clang-format -i main.c |
| Pick a base style | clang-format -i --style=Google main.c |
| Save a style for the project | clang-format --style=LLVM --dump-config > .clang-format |
| Format on save | The C/C++ extension in VS Code and CLion both use a .clang-format file if one is present |
When a .clang-format file is in your project folder, clang-format uses it automatically, so everyone on the team gets the same layout.
If you work across languages, these formatters run the same way, right in your browser: