LinthelmIntroductions to linters, static analysis and code-quality tools

Formatters

What is clang-format? An introduction to the LLVM Project's multi-language code formatter

By the Linthelm editorial team · Published · Updated

clang-format, also called ClangFormat, is a set of tools built on LibFormat that formats C, C++, Java, JavaScript, JSON, Objective-C, Protobuf and C# code. It works as a standalone command and through editor integrations. Style is controlled by preset styles or a .clang-format file.

Tool
clang-format
Made by
LLVM Project
Official site
clang.llvm.org/docs/ClangFormat.html
Category
Formatters

Who makes clang-format

clang-format is made by the LLVM Project. The official website, which hosts the ClangFormat documentation, is linked below this page.

Official website: clang.llvm.org/docs/ClangFormat.html

What clang-format is for

clang-format automatically formats source code so that it follows a chosen style. It is built on LibFormat, and it covers several languages rather than just one: C, C++, Java, JavaScript, JSON, Objective-C, Protobuf and C#.

It ships with preset styles, so a project can start formatting without writing a configuration. When a project needs its own rules, style configuration can be loaded from a .clang-format file in parent directories. A fallback style is used if no .clang-format file is found, so the tool still produces output in unconfigured directories.

Who clang-format is for

The vendor describes the audience as C/C++ developers and developers working in the other supported languages, along with people who use editor integrations. A team with a mixed codebase of, say, C++ and Protobuf files can use a single formatter for both.

Because it works both as a standalone tool and through editors, it suits developers who format on save as well as those who run it from the command line or scripts.

Notable capabilities

The command-line behavior is designed around pipes, in-place edits and tooling integration. These are the capabilities the documentation describes.

  • With no arguments it reads stdin and writes to stdout.
  • Files can be edited in place with -i.
  • A dry-run mode shows what would change without applying it.
  • It can format specific line ranges rather than whole files.
  • A configuration can be dumped to stdout to bootstrap a .clang-format file.
  • It can emit replacements as XML for tooling integration.
  • Filename hints determine the language and the config lookup when reading from stdin.
  • A .clang-format-ignore file makes it skip certain files.

How clang-format fits formatters

In the formatters category, clang-format is notable for spanning a group of languages through one underlying library, LibFormat, with a single style file format. Its stdin and XML replacement outputs make it easy for editors and other tools to call it.

Formatters restyle code and do not report defects, so they sit alongside linters and static analysis instead of replacing them. In the wider niche of code quality, a formatter such as clang-format settles layout automatically, and the dry-run mode gives a way to see what would change before anything is rewritten.

Frequently asked questions

What is clang-format used for?

clang-format formats C, C++, Java, JavaScript, JSON, Objective-C, Protobuf and C# code. It works as a standalone tool and through editor integrations.

Who develops clang-format?

clang-format is made by the LLVM Project, and it is built on LibFormat.

How do I configure clang-format?

Use a .clang-format file, which is loaded from parent directories, or one of the preset styles. You can dump a configuration to stdout to bootstrap a .clang-format file.

Can clang-format edit files in place?

Yes, files can be edited in place with -i. With no arguments it instead reads stdin and writes to stdout.

Can I stop clang-format from touching certain files?

Yes, a .clang-format-ignore file makes it skip certain files.

Sources. This introduction is based on the vendor's official pages, checked on 21 November 2026 (Asia/Dhaka):

Linthelm is independent and is not affiliated with LLVM Project. Product names belong to their owners. Features change; confirm details on the official website.