IntelliJ IDEA¶
With the plugin enabled, Reformat Code runs open-java-format instead of the IDE's built-in Java formatter, so the IDE and the build produce identical files. The IDE's own Java code style settings stop applying.
The plugin needs IntelliJ IDEA 2024.2 or later, or another JetBrains IDE with Java support, such as Android Studio.
Install¶
From the JetBrains Marketplace¶
- Open Settings, go to Plugins and switch to the Marketplace tab.
- Search for open-java-format and click Install.
- Restart the IDE.
The plugin page on the Marketplace has an Install to IDE button that does the same for an IDE that is already running.
From a file¶
A version that is not on the Marketplace yet can be installed from a release.
- Download
open-java-format-idea-plugin-21.0.2.zipfrom the latest release. Do not unpack it. - Open Settings, go to Plugins, click the gear icon and choose Install Plugin from Disk….
- Select the zip file and restart the IDE.
Enable it for a project¶
The plugin is off in every project until you turn it on.
- Open Settings and go to Tools → open-java-format Settings.
- Tick Enable open-java-format.

From then on Reformat Code, Ctrl+Alt+L or Option+Cmd+L on macOS, formats Java files with open-java-format.
Format on save¶
- Open Settings and go to Tools → Actions on Save.
- Tick Reformat code.
- Next to it, choose Java in the file list and Whole file instead of Changed lines.

Limiting it to Java keeps other files out: the IDE would reformat those with its own formatters.
Whole file formats the entire file, which is what the GitHub Action checks.
Changed lines formats only the lines you edited, the way formatDiff does.
Which formatter version runs¶
A project that applies the Gradle plugin takes the formatter version from the build. Every other project uses the version bundled with the IDE plugin.
By default the formatter runs in a process of its own, on the IDE's runtime, so the project SDK can be any version.
Native binary¶
Reformat Code starts the formatter as a new process for every file, and the Java-based formatter starts a JVM each time, which a whole directory makes you feel. The native binary starts without one: on an Apple silicon Mac a file takes about 40 ms instead of 430 ms.
It is a setting of the IDE and works in any project, whether Maven, Gradle or neither builds it.
- Open Settings and go to Tools → open-java-format Settings.
- Tick Use native binary, which shows while Enable open-java-format is ticked.
- Click Download next to No embedded version. The IDE downloads the binary of the plugin's version for your platform from Maven Central, checks it against its SHA-256 checksum and keeps it for every project. The line then reads Use embedded version and the version.
- Click OK. Until there is a binary to run, OK says so and keeps the page open.
Active formatter at the bottom of the page names what runs once you click OK, and follows the
page as you change it: the Java-based formatter, the binary's path, or the version that still
needs downloading. idea.log has a line starting with open-java-format: using each time the
plugin starts a formatter.
Projects that set openjavaformat.native.formatter
Up to 21.0.1 that Gradle property also switched the IDE to the native binary. It now applies to the build alone, so tick Use native binary once in such a project.
A binary of your own¶
To run another binary, such as one from the command line page, choose it in Binary under Use native binary. It takes the place of the embedded one; empty the field to go back to the embedded binary.
After an update of the plugin¶
The binary of the previous version keeps formatting. When a project opens, a notification says that a newer one is available, with Download and Ignore; Ignore holds until the plugin's next version. The settings page offers the same at any time: while the binary is of another version than the plugin, Update to and the plugin's version stand next to it. Once the newer binary is in, the old one is deleted.
Platforms¶
The binary is published for Linux with glibc on x86-64 and AArch64, macOS on Apple silicon and Intel, and Windows on x86-64. Anywhere else, such as Windows on ARM or Alpine, the settings page says there is none and the Java-based formatter runs, unless you choose a binary of your own.