DEV.co
Open-Source Databases · diffplug

spotless

Spotless is a build-system-agnostic code formatter that enforces consistent formatting across multiple languages (Java, Kotlin, JavaScript, SQL, etc.). It integrates with Gradle, Maven, and SBT, offering both format checking and automatic fixing with support for incremental builds and git-based ratcheting.

Source: GitHub — github.com/diffplug/spotless
5.5k
GitHub stars
541
Forks
Java
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorydiffplug/spotless
Ownerdiffplug
Primary languageJava
LicenseApache-2.0 — OSI-approved
Stars5.5k
Forks541
Open issues261
Latest releasemaven/3.8.0 (2026-06-29)
Last updated2026-06-29
Sourcehttps://github.com/diffplug/spotless

What spotless is

Spotless provides a composable formatter framework that abstracts individual language formatters (GoogleJavaFormat, Prettier, KtLint, etc.) behind a common `Function<String, String>` interface. It handles line-ending normalization, encoding validation, idempotency safeguards, and incremental build caching, with native plugins for Gradle and Maven and community support for SBT.

Quickstart

Get the spotless source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/diffplug/spotless.gitcd spotless# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Multi-language codebases with format enforcement

Enforce consistent formatting across Java, Kotlin, JavaScript, SQL, and other languages in a single build step, with automatic fixing via CI/CD pipelines.

Large teams needing automated code style consistency

Reduce code-review friction by automatically formatting on commit or pre-merge, eliminating style debates and ensuring all files conform to organization standards.

Gradle/Maven build pipeline integration

Native Gradle and Maven plugins enable seamless integration into existing builds with incremental formatting, build caching, and fast up-to-date checks.

Implementation considerations

  • Choose build-system plugin: native Gradle/Maven recommended; SBT is external (github.com/moznion/sbt-spotless).
  • Select formatters per language; each formatter (GoogleJavaFormat, Prettier, KtLint, etc.) has individual configuration and dependencies.
  • Configure encoding, line endings, and idempotency safeguards; defaults exist but review for special characters or cross-platform requirements.
  • Use `spotless:off` / `spotless:on` markers (Gradle/Maven only) for selective exclusions; unavailable in SBT.
  • Enable git ratcheting (Gradle/Maven only) to enforce formatting only on changed files, reducing CI time.

When to avoid it — and what to weigh

  • Custom formatter not in supported list — If your language or formatter is not in Spotless' feature matrix (e.g., ClangFormat only for Gradle, no SBT support for most formatters), you may need fallback tooling.
  • Minimal formatting overhead is critical — Spotless adds build task overhead; if you need only inline editor formatting without CI checks, consider editor plugins (VS Code, IntelliJ) instead.
  • SBT-only projects with advanced features needed — SBT support is external and community-maintained, with gaps in features like ratcheting, git-driven line-ending config, and encoding safeguards compared to Gradle/Maven.
  • Pre-existing complex custom formatting pipelines — Migrating existing bespoke formatter configs may require significant rework; evaluate compatibility before adoption.

License & commercial use

Licensed under Apache License 2.0 (Apache-2.0), a permissive OSI-approved open-source license.

Apache-2.0 permits commercial use, modification, and distribution with minimal restrictions (attribution, license notice, liability disclaimer). No commercial restrictions noted in license terms; use for proprietary projects is permitted.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

Spotless itself does not validate or sanitize code logic; it performs syntax-safe formatting only. When using external formatters (Prettier, KtLint, etc.), ensure their dependencies are from trusted sources and kept updated. No built-in vulnerability scanning; rely on dependency management (gradle/maven) and third-party tools (e.g., Dependabot).

Alternatives to consider

Prettier (JavaScript/TypeScript/JSON only)

Opinionated, zero-config formatter for web languages; requires manual integration for other languages and build systems.

EditorConfig + language-specific linters (ESLint, Pylint, etc.)

Lightweight, editor-native approach; lacks centralized build integration and automatic fixing across multiple languages.

Google Java Format + manual per-language setup

Single-language formatters; requires custom scripting to compose and integrate; higher overhead than Spotless.

Software development agency

Build on spotless with DEV.co software developers

Integrate Spotless into your Gradle or Maven build to automate formatting checks and fixes. Reduce code-review friction, enforce organizational standards, and support 15+ languages with composable formatters.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

spotless FAQ

Can I use Spotless with only Maven or only Gradle?
Yes. Spotless is build-system-agnostic with native Maven and Gradle plugins. SBT support is external. You need only the plugin for your build system.
Does Spotless support my language or formatter?
Consult the feature matrix in the README. 15+ language/formatter combinations are listed; some formatters are Gradle-only. If not listed, you may use generic steps (LicenseHeaderStep, ReplaceRegexStep) or custom JSR223 scripts (Maven).
What is git ratcheting and should I use it?
Ratcheting enforces formatting only on changed files (vs. `origin/main` or another ref), speeding up CI for large codebases. Available in Gradle and Maven; recommended for incremental adoption.
Does Spotless slow down my build?
Gradle and Maven offer incremental checks and build caching; formatting only changed files should add <10% overhead in most cases. Full-repo formatting on clean checkout will be slower; use build cache to mitigate.

Custom software development services

Need help beyond evaluating spotless? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source databases integrations — and maintain them long-term.

Standardize code formatting across your team

Integrate Spotless into your Gradle or Maven build to automate formatting checks and fixes. Reduce code-review friction, enforce organizational standards, and support 15+ languages with composable formatters.