A Python code formatter that reformats source files to a configurable style, based on clang-format's layout algorithm.
diffplug/spotless
A build-plugin framework for Gradle and Maven that runs code formatters and linters across many languages and file types.
- Stars
- 5,720
- Forks
- 565
- Open issues
- 251
- Last commit
- 5 days ago
What is it?
Spotless is a build-tool plugin that applies code formatters to a project's source files and fails the build when files are not formatted. It works with Gradle and Maven, with an SBT plugin maintained separately. Running a single command such as spotlessApply rewrites violating files, and spotlessCheck reports them, so formatting can be enforced in CI.
Spotless supports a wide range of languages, including Java, Kotlin, Groovy, Scala, JavaScript, TypeScript, SQL, YAML, Markdown, Python, C++, and shell scripts. It wraps well-known formatters such as google-java-format, ktlint, Prettier, Black, and clang-format, and it also offers generic steps for regex replacement, whitespace trimming, license headers, and running arbitrary native commands.
The project also handles integration concerns: idempotency checks, encoding and line-ending handling, Git-based ratcheting to format only changed files, and Gradle build-cache and configuration-cache support.
Key features
- 01Checks and auto-fixes formatting with spotlessCheck and spotlessApply tasks.
- 02Supports Java, Kotlin, Groovy, Scala, JavaScript, TypeScript, SQL, YAML, Markdown, and more.
- 03Wraps formatters such as google-java-format, ktlint, Prettier, Black, and clang-format.
- 04Ratchets formatting against a Git ref so only changed files are processed.
- 05Includes generic steps for regex replacement, whitespace trimming, and license headers.
Use cases
- Enforcing a consistent code style across a multi-language Java or Kotlin monorepo in CI.
- Auto-formatting only the files changed in a pull request during local development.
- Applying license headers or import-order rules to every source file in a build.
- Formatting SQL, YAML, or Markdown alongside application code using one tool.
Quick start
- 1
Add the Spotless plugin to your Gradle or Maven build, following the plugin-gradle or plugin-maven guide
- 2
Apply formatting with Gradle
./gradlew spotlessApply - 3
Apply formatting with Maven
mvn spotless:apply
Things to know
- First-party support covers only Gradle and Maven; the SBT integration is external.
- Feature and formatter support varies by build tool, so some steps are available only on Gradle.
In collections
Topics
FAQ
- What is spotless?
- A build-plugin framework for Gradle and Maven that runs code formatters and linters across many languages and file types. Spotless is a build-tool plugin that applies code formatters to a project's source files and fails the build when files are not formatted. It works with Gradle and Maven, with an SBT plugin maintained separately. Running a single command such as spotlessApply rewrites violating files, and spotlessCheck reports them, so formatting can be enforced in CI.
- Is spotless free to use? What license does it have?
- spotless is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is spotless still maintained?
- Actively maintained. The last commit to spotless was on Nov 2, 2026.
- What can I use spotless for?
- Enforcing a consistent code style across a multi-language Java or Kotlin monorepo in CI. Auto-formatting only the files changed in a pull request during local development. Applying license headers or import-order rules to every source file in a build. Formatting SQL, YAML, or Markdown alongside application code using one tool.
- How do I install spotless?
- Add the Spotless plugin to your Gradle or Maven build, following the plugin-gradle or plugin-maven guide Apply formatting with Gradle: ./gradlew spotlessApply Apply formatting with Maven: mvn spotless:apply
- Where can I get spotless?
- The source code and installation instructions are on GitHub: https://github.com/diffplug/spotless
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Ruby static code analyzer and formatter that enforces community Ruby Style Guide rules and can auto-fix many violations.
Black is an opinionated, deterministic Python code formatter that rewrites files in place with minimal diffs.
A PHP command-line tool that automatically fixes code to follow PHP coding standards such as PER-CS and Symfony.
A Python utility and library that automatically sorts and groups your import statements.
A Gradle plugin that publishes Java, Kotlin and Android libraries, with sources and javadoc, to Maven Central or other Nexus repositories.