This problem can be solve installing the google-java-format Plugin.

  1. Open plugins window (CTRL+Shift+A): plugins

  2. Click on browse repositories.

  3. Search for google-java-format

  4. Install the plugin.

  5. Restart the IDE.

  6. Enable the plugin executing the action (Ctrl+Shift+A): Reformat with google-java-format Update: in the newer version of the plugin select Reformat since the plugin overrides / enhances the functionality of the standard "Reformat" command.

Additional notes from the google-java-format README

The plugin will be disabled by default. To enable it in the current project, go to File→Settings...→google-java-format Settings (or IntelliJ IDEA→Preferences...→Other Settings→google-java-format Settings on macOS) and check the Enable google-java-format checkbox. (A notification will be presented when you first open a project offering to do this for you.)

To enable it by default in new projects, use File→Other Settings→Default Settings....

Answer from Geekecom on Stack Overflow
🌐
JetBrains
jetbrains.com › help › idea › reformat-and-rearrange-code.html
Reformat code | IntelliJ IDEA Documentation
3 weeks ago - Reformat your code (Ctrl+Alt+L). IntelliJ IDEA will reformat your code in accordance with the current style settings, keeping existing formatting for the rules which you've selected.
🌐
JetBrains
blog.jetbrains.com › home › intellij idea › how to format java code
How to Format Java Code - The JetBrains Blog
June 6, 2024 - While coding with IntelliJ IDEA, we don’t need to manually format our code, as the IDE does it automatically. For example, if we press Enter (Windows/Linux) or ⏎ (macOS), the caret goes into the correct place for us to start typing. The same is true if we use other shortcuts like Shift+Enter (Windows/Linux) or ⇧⏎ (macOS) to move to the next line, or if we use code generation. If we copy some code that is inconsistently formatted and paste it into the editor, IntelliJ IDEA will format the code according to the project’s standards.
🌐
GitHub
github.com › google › google-java-format
GitHub - google/google-java-format: Reformats Java source code to comply with Google Java Style. · GitHub
1 month ago - This is a deliberate design decision to unify our code formatting on a single format. A google-java-format IntelliJ plugin is available from the plugin repository. To install it, go to your IDE's settings and select the Plugins category.
Author: google
🌐
JetBrains
plugins.jetbrains.com › plugin › 23827-external-java-formatter
External Java Formatter - IntelliJ IDEs Plugin | Marketplace
This plugin enables the integration of any Java formatter into the project. Unlike other formatters, the SDK of the project is used instead of the Intellij VM when the...
🌐
JetBrains
plugins.jetbrains.com › plugin › 8527-google-java-format
google-java-format - IntelliJ IDEs Plugin | Marketplace
Formats source code using the google-java-format tool. This plugin requires additional IDE configuration. For more information, read the documentation.
🌐
JetBrains
jetbrains.com › guide › java › tutorials › reading-code › formatting
Formatting - JetBrains Guide
March 1, 2024 - IntelliJ IDEA will take care of formatting the code while we are writing code. If we encounter code that is not properly formatted, we can have IntelliJ IDEA reformat the code for us.
Find elsewhere
🌐
GitHub
github.com › palantir › palantir-java-format
GitHub - palantir/palantir-java-format: A modern, lambda-friendly, 120 character Java formatter. · GitHub
A palantir-java-format IntelliJ plugin is available from the plugin repository. To install it, go to your IDE's settings and select the Plugins category. Click the Marketplace tab, search for the palantir-java-format plugin, and click the Install ...
Author: palantir
Author: WasiqB
🌐
JetBrains
plugins.jetbrains.com › docs › intellij › code-formatting.html
Code Formatter | IntelliJ Platform Plugin SDK
3 weeks ago - The IntelliJ Platform already provides concrete implementations of FormattingModel that should be used instead of implementing a custom one. Formatters for custom (programming) languages are usually built so that they mirror the PSI structure of the file. Although not required, this approach is reasonable when thinking about, for example, Java code where the top-level formatting block covers the entire file, its children cover individual classes, blocks on the next level cover methods inside classes, and so on.
🌐
JetBrains
jetbrains.com › help › idea › code-style.html
Code style and formatting | IntelliJ IDEA Documentation
February 11, 2024 - Once the rules are configured, you can invoke the Reformat code action that changes the formatting of your code in the selected code fragment, within a file, or across your entire project.
Starred by 514 users
Forked by 117 users
Languages: Java 93.9% | HTML 5.8% | JavaScript 0.3%
🌐
JetBrains
plugins.jetbrains.com › docs › intellij › formatter.html
16. Formatter | IntelliJ Platform Plugin SDK
March 19, 2025 - <extensions defaultExtensionNs="com.intellij"> <lang.formatter language="Simple" implementationClass="org.intellij.sdk.language.SimpleFormattingModelBuilder"/> </extensions>
🌐
Etendo
docs.etendo.software › developer-guide › etendo-classic › getting-started › installation › intellij-code-formatting
Code Formatting Style in IntelliJ - Etendo Documentation
First, download the following IntelliJ formatting file. Open IntelliJ IDEA Settings · Search Code Style → Java · Click the gear icon → Import Schema → IntelliJ IDEA code style XML. Select the file downloaded first and import the schema. This work is licensed under CC BY-SA 2.5 ES by ...
🌐
Reddit
reddit.com › r/java › codestyle and formatters
r/java on Reddit: Codestyle and formatters
October 21, 2024 -

Hi y'all,

My team would like to standardise code formatting and enforce it in CI. We've tried google-java-formatter but it doesn't look nearly as good as inteliJ's default settings.

Ideally, we'd like to export inteliJs defaults (to have the benefits of built in formatter) and use something that would enforce it on CI build. Has anyone done it? What are your pipelines like? Any tips and tricks?

🌐
GitHub
github.com › ICIJ › intellij-code-formatter
GitHub - ICIJ/intellij-code-formatter: A standalone code formatter that leverages IntelliJ IDEA's powerful formatting engine without requiring a full IDE installation · GitHub
July 29, 2026 - A standalone code formatter that leverages IntelliJ IDEA's powerful formatting engine without requiring a full IDE installation. The CLI recursively formats Java source directories; the underlying library also supports Kotlin, XML, JSON, YAML, ...
Author: ICIJ
🌐
tr ouwens
jqno.nl › post › 2024 › 08 › 24 › why-are-there-no-decent-code-formatters-for-java
Why are there no decent code formatters for Java? - tr ouwens
August 24, 2024 - On the one hand, they make google-java-format’s crappy formatting much, much better. But at the same time, they don’t offer a command-line tool. Yes, there’s Maven integration, and yes, there’s an IntelliJ plugin. But no official command-line tool.
🌐
GitHub
github.com › mschieder › idea-code-formatter
GitHub - mschieder/idea-code-formatter · GitHub
$ java -jar idea-code-formatter-1.0.0-SNAPSHOT.jar IntelliJ IDEA 2023.1, build IC-231.8109.175 Formatter Usage: format [-h] [-r|-R] [-d|-dry] [-s|-settings settingsPath] [-charset charsetName] [-allowDefaults] path1 path2... -h|-help Show a help message and exit.
Author: mschieder
🌐
CodeGym
codegym.cc › java blog › random › intellij idea: coding style and code formatting
IntelliJ IDEA: Coding style and code formatting
December 19, 2023 - Choose File -> Settings in the IDEA menu (or press Ctrl+Alt+S). Enter "Code style" in the search field in the settings window. In the "Code style" section, you can specify settings for more languages than just Java.
🌐
GitHub
github.com › a-havrysh › vscode-intellij-code-formatter
GitHub - a-havrysh/vscode-intellij-code-formatter: A standalone code formatter that leverages IntelliJ IDEA's powerful formatting engine without requiring a full IDE installation · GitHub
A standalone code formatter that leverages IntelliJ IDEA's powerful formatting engine without requiring a full IDE installation. Format Java, Kotlin, XML, JSON, YAML, Groovy, and Properties files from the command line with IntelliJ's high-quality ...
Author: a-havrysh