Home

ClangFormat

ClangFormat is an automated code formatter that is part of the LLVM Clang project. It reformats source code to a consistent style across a codebase and is language aware, with primary support for C, C++, and Objective-C, as well as several other languages supported by clang-format such as Java and JavaScript. Formatting rules are defined in a configuration file named .clang-format (or _clang-format on Windows), using a YAML-based syntax.

Configuration and style options are centralized in the .clang-format file. Users can choose a base style with

Usage and workflow are straightforward: clang-format can format files in place or emit formatted text to standard

Integration and ecosystem: clang-format is widely integrated into editors and IDEs (for example VS Code, Vim/Neovim,

History and licensing: clang-format was developed as part of the LLVM project and is distributed under the

BasedOnStyle
(for
example
Google,
LLVM,
WebKit,
or
Mozilla)
and
override
specific
options
such
as
ColumnLimit,
IndentWidth,
UseTab,
BreakBeforeBraces,
and
many
others.
If
no
configuration
is
found,
clang-format
applies
a
default
style.
The
configuration
can
be
placed
in
the
project
tree
and
inherited
by
files
within
its
directories.
output,
allowing
integration
with
editors,
IDEs,
or
automated
workflows.
It
is
commonly
invoked
as
part
of
development
environments,
build
systems,
or
pre-commit
checks
to
enforce
a
consistent
code
style
across
teams.
Emacs,
and
JetBrains
products)
and
supports
various
tooling
workflows,
including
continuous
integration
and
code
reviews.
Its
configurability
enables
teams
to
maintain
a
uniform
appearance
while
accommodating
project-specific
conventions.
LLVM
project
license
(Apache
2.0
with
LLVM
exception).
It
has
become
a
standard
tool
for
enacting
consistent
formatting
across
large
codebases.