LinthelmIntroductions to linters, static analysis and code-quality tools

Formatters

What is google-java-format? An introduction to Google's Java formatter

By the Linthelm editorial team · Published · Updated

google-java-format is a program from Google that reformats Java source code to comply with Google Java Style. It deliberately offers almost no configurability, with the goal of unifying code formatting on a single format. It is open source under the Apache License 2.0.

Tool
google-java-format
Made by
Google
Official site
github.com/google/google-java-format
Category
Formatters

Who makes google-java-format

google-java-format is made by Google and developed on GitHub. The official website is linked below and leads to the project repository.

The project is released as open source under the Apache License 2.0.

Official website: github.com/google/google-java-format

What google-java-format is for

google-java-format is for reformatting Java source code so that it complies with Google Java Style. It can format whole files, or limit formatting to specific lines or offsets. Output can be printed to stdout or used to replace the file in place.

A script is provided to reformat only the changed lines of a patch, which is useful when a change should not touch unrelated code.

The tool deliberately offers almost no configurability. The purpose is to unify code formatting on a single format rather than to support many house styles.

Who google-java-format is for

The vendor names two audiences: Java developers and software that generates Java code. Developers get editor and build integrations, while generator authors can use it as a library to format the Java they emit.

It must run on a JDK at least as new as the Java language version of the files being formatted. GraalVM-based native binaries are available as an alternative to running on a JDK.

Notable capabilities

The tool has few settings, but it connects to common Java workflows. These are the capabilities from the verified facts.

  • The --style flag selects Google or AOSP style, with Google as the default.
  • The column limit is configurable and defaults to 100.
  • Small non-whitespace cleanups such as removing redundant semicolons can be disabled.
  • Import sorting and unused import removal can be disabled.
  • An IntelliJ plugin is available from the plugin repository, and the Eclipse plugin adds Google (2-space) and AOSP (4-space) formatter implementations.
  • A Maven plugin can deploy it as a pre-commit git hook.
  • A GitHub Action can automatically format Java files on push.
  • It can be used as a library in software that generates Java code.

How google-java-format fits formatters

Formatters apply a consistent layout to code without changing what it does. google-java-format is a single-language formatter for Java that follows one published style, Google Java Style, with the AOSP style available through a flag.

Its place in the category is defined by restraint. Instead of exposing many settings, it keeps the options narrow, which is how it aims to unify formatting on a single format.

For Linthelm's wider niche of linters, static analysis and code quality, it covers formatting of Java code. Hooks and automation, such as the Maven pre-commit hook and the GitHub Action that formats on push, let it run as part of the same workflow as other quality checks.

Frequently asked questions

What is google-java-format used for?

It is used to reformat Java source code to comply with Google Java Style. It can format whole files or limited lines or offsets.

Who develops google-java-format?

google-java-format is developed by Google and is open source under the Apache License 2.0.

Does google-java-format support AOSP style?

Yes. The --style flag selects Google or AOSP style, with Google as the default.

Can I change the column limit in google-java-format?

Yes. The column limit is configurable and defaults to 100.

Does google-java-format need a JDK?

It must run on a JDK at least as new as the Java language version of the files being formatted. GraalVM-based native binaries are available as an alternative.

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 Google. Product names belong to their owners. Features change; confirm details on the official website.