openjavaformat/open-java-format

A modern, lambda-friendly, 120 character Java formatter.

Java

3

2,145 commits

updated Sep 23, 2026

See the code

See what people are saying

README

CI License Maven Central Gradle Plugin Portal JetBrains Marketplace Manifesto

open-java-format

A modern, lambda-friendly, 120-character Java formatter — built in the open.

Documentation: openjavaformat.dev

open-java-format is released and developed independently. It began as a community fork of palantir-java-format, which is itself a fork of google-java-format, and every artifact is now built and published from this repository.

WhereWhat
Maven Centraldev.openjavaformat:open-java-format, with -spi, -native and -jdk-bootstrap
Gradle Plugin Portaldev.openjavaformat.java-format
JetBrains Marketplacethe IntelliJ IDEA plugin
GitHub Releasesnative binaries, a runnable jar, the Gradle, IntelliJ and Eclipse plugins, every file signed

Why the project exists is in the manifesto.

Get started

Each page is short and every command on it was run against the published artifacts.

What the output looks like

Lines are up to 120 characters wide. A lambda stays on the line where it starts, and a long call chain breaks into one call per line.

google-java-format:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager()
            .withPlugin(
                    "maven-publish",
                    plugin -> {
                        project.getExtensions()
                                .getByType(PublishingExtension.class)
                                .getPublications()
                                .withType(MavenPublication.class)
                                .configureEach(
                                        publication ->
                                                publication.versionMapping(
                                                        mapping -> {
                                                            mapping.allVariants(
                                                                    VariantVersionMappingStrategy
                                                                            ::fromResolutionResult);
                                                        }));
                    });
}

open-java-format:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager().withPlugin("maven-publish", plugin -> {
        project.getExtensions()
                .getByType(PublishingExtension.class)
                .getPublications()
                .withType(MavenPublication.class)
                .configureEach(publication -> publication.versionMapping(mapping -> {
                    mapping.allVariants(VariantVersionMappingStrategy::fromResolutionResult);
                }));
    });
}

Coming from palantir-java-format

  • Identical output. 2.98.0.1 is the code of palantir-java-format 2.98.0, renamed and rebuilt in the open. The fourth number counts builds of an upstream version.
  • Identical Java packages. com.palantir.javaformat.* stays for the whole 2.x line, so your code and the SPI keep working.
  • One-line migration. Change the coordinates below. Nothing else.

Changes to the formatter's output wait for 3.0.

palantir-java-formatopen-java-format
Maven groupcom.palantir.javaformatdev.openjavaformat
Corepalantir-java-formatopen-java-format
SPIpalantir-java-format-spiopen-java-format-spi
Native imagepalantir-java-format-nativeopen-java-format-native
JDK bootstrappalantir-java-format-jdk-bootstrapopen-java-format-jdk-bootstrap
Gradle plugin artifactgradle-palantir-java-formatgradle-open-java-format
Gradle plugin IDscom.palantir.java-format, -idea, -spotless, -providerdev.openjavaformat.java-format, -idea, -spotless, -provider
IntelliJ plugin IDpalantir-java-formatopen-java-format
Eclipse plugin bundlepalantir-java-format-eclipse-pluginopen-java-format-eclipse-plugin
CLI style flag--palantir, -palantir--ojf, -ojf
Formatter stylePALANTIROJF
Native formatter Gradle propertypalantir.native.formatteropenjavaformat.native.formatter
Java packagescom.palantir.javaformat.*unchanged in 2.x
Version numbers2.98.02.98.0.1

Building and testing locally

mise pins the tooling: mise.toml installs Temurin 21 and act.

mise trust && mise install
./gradlew test      # what the CI build job runs

-PjavaRuntime=25 runs the same tests on JDK 25, as CI's jdk jobs do for 25, 26 and 27. The code is compiled for Java 21 either way. Gradle has to find that JDK: installed with mise, or named with -Porg.gradle.java.installations.paths=/path/to/jdk.

Nothing inside the build downloads a JDK. gradle.properties turns toolchain auto-download off and reads the installations from JDK21_HOME and GRAALVM_HOME, so a missing JDK is an error you can read rather than a silent download.

The native image needs a GraalVM 25 behind GRAALVM_HOME. CI installs it with graalvm/setup-graalvm and builds the image in a job of its own:

./gradlew -PnativeImage=true :open-java-format-native:nativeCompile

GraalVM has to come from outside Gradle: unpacking a JDK that Gradle downloaded itself does not preserve the symlink GraalVM ships at bin/native-image, and nativeCompile then fails on an empty, unexecutable file.

Running CI locally

The workflows run under act in Docker, so a change to .github/workflows can be checked before it is pushed:

mise run ci:list     # what jobs exist
mise run ci:lint     # dry-run every job: resolves images, actions and steps, executes nothing
mise run ci:build    # actually run the linux jar+native build job
mise run ci:native   # actually run the linux-aarch64 native job

Two caveats:

  • act cannot containerise macOS, so the macos-aarch64 leg has to be checked by building the native image on a Mac.
  • On an Apple Silicon host the ubuntu-24.04 container runs as arm64, so the job labelled linux-x86-64 produces an aarch64 binary locally. Fine for exercising the workflow, not a substitute for real CI.

License and attribution

This project is a fork of palantir-java-format, which is itself a fork of google-java-format. It is distributed under the same Apache 2.0 License, and it keeps every upstream copyright notice — from both projects — permanently.

Neither Palantir Technologies Inc. nor Google LLC endorses, sponsors or is affiliated with this fork. "Palantir" and "Google" are trademarks of their respective owners, and Apache 2.0 §6 grants no rights to them; the rename described in this README exists in part for that reason.

(c) Copyright 2019 Palantir Technologies Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

Original work copyrighted by Google under the same license:

Copyright 2015 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

Contributors

(top 30 of 98)

svc-excavator-bot

1,214 commits

cushon

352 commits

svc-autorelease

123 commits

dansanduleac

72 commits

openjavaformat/open-java-format

A modern, lambda-friendly, 120 character Java formatter.

Java

3

2,145 commits

updated Sep 23, 2026

See the code

See what people are saying

README

CI License Maven Central Gradle Plugin Portal JetBrains Marketplace Manifesto

open-java-format

A modern, lambda-friendly, 120-character Java formatter — built in the open.

Documentation: openjavaformat.dev

open-java-format is released and developed independently. It began as a community fork of palantir-java-format, which is itself a fork of google-java-format, and every artifact is now built and published from this repository.

WhereWhat
Maven Centraldev.openjavaformat:open-java-format, with -spi, -native and -jdk-bootstrap
Gradle Plugin Portaldev.openjavaformat.java-format
JetBrains Marketplacethe IntelliJ IDEA plugin
GitHub Releasesnative binaries, a runnable jar, the Gradle, IntelliJ and Eclipse plugins, every file signed

Why the project exists is in the manifesto.

Get started

Each page is short and every command on it was run against the published artifacts.

What the output looks like

Lines are up to 120 characters wide. A lambda stays on the line where it starts, and a long call chain breaks into one call per line.

google-java-format:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager()
            .withPlugin(
                    "maven-publish",
                    plugin -> {
                        project.getExtensions()
                                .getByType(PublishingExtension.class)
                                .getPublications()
                                .withType(MavenPublication.class)
                                .configureEach(
                                        publication ->
                                                publication.versionMapping(
                                                        mapping -> {
                                                            mapping.allVariants(
                                                                    VariantVersionMappingStrategy
                                                                            ::fromResolutionResult);
                                                        }));
                    });
}

open-java-format:

private static void configureResolvedVersionsWithVersionMapping(Project project) {
    project.getPluginManager().withPlugin("maven-publish", plugin -> {
        project.getExtensions()
                .getByType(PublishingExtension.class)
                .getPublications()
                .withType(MavenPublication.class)
                .configureEach(publication -> publication.versionMapping(mapping -> {
                    mapping.allVariants(VariantVersionMappingStrategy::fromResolutionResult);
                }));
    });
}

Coming from palantir-java-format

  • Identical output. 2.98.0.1 is the code of palantir-java-format 2.98.0, renamed and rebuilt in the open. The fourth number counts builds of an upstream version.
  • Identical Java packages. com.palantir.javaformat.* stays for the whole 2.x line, so your code and the SPI keep working.
  • One-line migration. Change the coordinates below. Nothing else.

Changes to the formatter's output wait for 3.0.

palantir-java-formatopen-java-format
Maven groupcom.palantir.javaformatdev.openjavaformat
Corepalantir-java-formatopen-java-format
SPIpalantir-java-format-spiopen-java-format-spi
Native imagepalantir-java-format-nativeopen-java-format-native
JDK bootstrappalantir-java-format-jdk-bootstrapopen-java-format-jdk-bootstrap
Gradle plugin artifactgradle-palantir-java-formatgradle-open-java-format
Gradle plugin IDscom.palantir.java-format, -idea, -spotless, -providerdev.openjavaformat.java-format, -idea, -spotless, -provider
IntelliJ plugin IDpalantir-java-formatopen-java-format
Eclipse plugin bundlepalantir-java-format-eclipse-pluginopen-java-format-eclipse-plugin
CLI style flag--palantir, -palantir--ojf, -ojf
Formatter stylePALANTIROJF
Native formatter Gradle propertypalantir.native.formatteropenjavaformat.native.formatter
Java packagescom.palantir.javaformat.*unchanged in 2.x
Version numbers2.98.02.98.0.1

Building and testing locally

mise pins the tooling: mise.toml installs Temurin 21 and act.

mise trust && mise install
./gradlew test      # what the CI build job runs

-PjavaRuntime=25 runs the same tests on JDK 25, as CI's jdk jobs do for 25, 26 and 27. The code is compiled for Java 21 either way. Gradle has to find that JDK: installed with mise, or named with -Porg.gradle.java.installations.paths=/path/to/jdk.

Nothing inside the build downloads a JDK. gradle.properties turns toolchain auto-download off and reads the installations from JDK21_HOME and GRAALVM_HOME, so a missing JDK is an error you can read rather than a silent download.

The native image needs a GraalVM 25 behind GRAALVM_HOME. CI installs it with graalvm/setup-graalvm and builds the image in a job of its own:

./gradlew -PnativeImage=true :open-java-format-native:nativeCompile

GraalVM has to come from outside Gradle: unpacking a JDK that Gradle downloaded itself does not preserve the symlink GraalVM ships at bin/native-image, and nativeCompile then fails on an empty, unexecutable file.

Running CI locally

The workflows run under act in Docker, so a change to .github/workflows can be checked before it is pushed:

mise run ci:list     # what jobs exist
mise run ci:lint     # dry-run every job: resolves images, actions and steps, executes nothing
mise run ci:build    # actually run the linux jar+native build job
mise run ci:native   # actually run the linux-aarch64 native job

Two caveats:

  • act cannot containerise macOS, so the macos-aarch64 leg has to be checked by building the native image on a Mac.
  • On an Apple Silicon host the ubuntu-24.04 container runs as arm64, so the job labelled linux-x86-64 produces an aarch64 binary locally. Fine for exercising the workflow, not a substitute for real CI.

License and attribution

This project is a fork of palantir-java-format, which is itself a fork of google-java-format. It is distributed under the same Apache 2.0 License, and it keeps every upstream copyright notice — from both projects — permanently.

Neither Palantir Technologies Inc. nor Google LLC endorses, sponsors or is affiliated with this fork. "Palantir" and "Google" are trademarks of their respective owners, and Apache 2.0 §6 grants no rights to them; the rename described in this README exists in part for that reason.

(c) Copyright 2019 Palantir Technologies Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

Original work copyrighted by Google under the same license:

Copyright 2015 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

Contributors

(top 30 of 98)

svc-excavator-bot

1,214 commits

cushon

352 commits

svc-autorelease

123 commits

dansanduleac

72 commits

Languages

Java

97.0%

TypeScript

2.2%