# diffplug/spotless

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/diffplug-spotless).**

5,527 stars · 536 forks · Java · Apache-2.0

## Links

- GitHub: https://github.com/diffplug/spotless
- awesome-repositories: https://awesome-repositories.com/repository/diffplug-spotless.md

## Description

Spotless is a multi-language formatting orchestrator and Gradle plugin that automates code styling across various programming languages within a single build pipeline. It functions as a coordinator for multiple third-party formatters, a code style linting tool, and a system for inserting and updating standardized license headers.

The project distinguishes itself through git-integrated style enforcement, using pre-push hooks and git references to apply formatting only to modified files or lines. It supports shared build configurations, allowing formatting rules to be distributed and loaded across multiple projects via remote artifacts to maintain a single source of truth.

The tool covers a broad range of capabilities, including source code text transformation via regular expressions and JSON patches, import management, and whitespace standardization. It integrates with a wide array of external binaries and tools for languages such as Java, Python, Kotlin, C++, Go, and TypeScript. Additional functionality includes formatting verification to ensure idempotency and incremental optimization to skip unchanged files.

## Tags

### Development Tools & Productivity

- [Formatting Plugins](https://awesome-repositories.com/f/development-tools-productivity/build-plugin-architectures/gradle-convention-plugins/formatting-plugins.md) — Provides a Gradle plugin that automates multi-language code styling and formatting using integrated third-party tools.
- [Multi-Language Formatters](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-formatting-tools/multi-language-formatters.md) — Provides a central orchestrator that applies consistent formatting rules across multiple programming languages within a single build pipeline.
- [Multi-Language Code Formatters](https://awesome-repositories.com/f/development-tools-productivity/multi-language-code-formatters.md) — Automates consistent coding styles across various programming languages within a single build pipeline.
- [Line Ending Standards](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/code-formatting-utilities/formatting-rules/line-ending-standards.md) — Enforces consistent line ending styles (CRLF or LF) and character encoding across different operating systems. ([source](https://github.com/diffplug/spotless/blob/main/plugin-gradle))
- [Indentation Standardization](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/code-formatting-utilities/formatting-rules/line-ending-standards/whitespace-enforcement/indentation-standardization.md) — Standardizes source code indentation by converting between tabs and spaces based on a specified ratio. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/generic/IndentStep.java))
- [External Command Execution](https://awesome-repositories.com/f/development-tools-productivity/external-command-execution.md) — Executes local system commands with custom arguments to format source files using external binaries. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/generic/NativeCmdStep.java))
- [Git Style Verifiers](https://awesome-repositories.com/f/development-tools-productivity/git-repository-integrators/git-style-verifiers.md) — Uses pre-push hooks and git references to ensure style compliance only on modified files.
- [Line-Level Ratcheting](https://awesome-repositories.com/f/development-tools-productivity/incremental-formatting-optimizations/line-level-ratcheting.md) — Restricts style changes to only the lines modified relative to a specific git reference. ([source](https://github.com/diffplug/spotless/blob/main/README.md))
- [Incremental Style Enforcement](https://awesome-repositories.com/f/development-tools-productivity/incremental-style-enforcement.md) — Limits formatting operations to specific lines or files modified relative to a git commit or branch to ease adoption.
- [License Management Tools](https://awesome-repositories.com/f/development-tools-productivity/license-management-tools.md) — Inserts and updates standardized copyright notices and license headers at the top of source files.
- [Shared Formatting Configurations](https://awesome-repositories.com/f/development-tools-productivity/shared-formatting-configurations.md) — Provides the ability to share and distribute a single source of truth for formatting rules across multiple projects via remote artifacts.
- [Static Code Linting](https://awesome-repositories.com/f/development-tools-productivity/static-code-linting.md) — Captures line-specific formatting violations and style errors without modifying the source files. ([source](https://github.com/diffplug/spotless/blob/main/CHANGES.md))
- [File Termination Newlines](https://awesome-repositories.com/f/development-tools-productivity/string-formatting-utilities/newline-characters/file-termination-newlines.md) — Ensures every source file ends with a newline character for consistent file termination. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/generic/EndWithNewlineStep.java))
- [External CLI Formatter Integration](https://awesome-repositories.com/f/development-tools-productivity/terminal-shell-cli/cli-tooling-frameworks/cli-tooling/distribution-extensibility/external-cli-formatter-integration.md) — Executes local binary tools or package utilities to format code using third-party software. ([source](https://github.com/diffplug/spotless/blob/main/CHANGES.md))
- [Git Hook Automations](https://awesome-repositories.com/f/development-tools-productivity/automated-formatting-frameworks/git-hook-automations.md) — Installs a pre-push git hook that automatically checks for style issues and applies fixes before code is pushed. ([source](https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md))
- [Gradual Adoption Strategies](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/code-formatting-utilities/formatting-rules/line-ending-standards/whitespace-enforcement/formatting-enforcement/gradual-adoption-strategies.md) — Limits style changes to files modified since a specific git reference to facilitate the gradual adoption of new standards. ([source](https://github.com/diffplug/spotless/blob/main/plugin-gradle))
- [Code Formatting Tools](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-formatting-tools.md) — Applies Prettier styling to source files by managing the required execution environment. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java))
- [Embedded Code Formatters](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-formatting-tools/embedded-code-formatters.md) — Styles code blocks found within other files using regular expressions or markers. ([source](https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md))
- [Go Formatting Tools](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-formatting-tools/go-formatting-tools.md) — Executes the gofmt tool to enforce consistent coding styles in Go projects. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/go/GofmtFormatStep.java))
- [SQL Formatters](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-formatting-tools/sql-formatters.md) — Standardizes the layout of SQL scripts using the DBeaver formatting implementation. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/sql/DBeaverSQLFormatterStep.java))
- [Groovy Formatters](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/groovy-formatters.md) — Applies the Groovy-Eclipse formatter to ensure consistent styling across Groovy source files. ([source](https://github.com/diffplug/spotless/blob/main/lib-extra/src/main/java/com/diffplug/spotless/extra/groovy/GrEclipseFormatterStep.java))
- [Custom Formatting Rules](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/static-analysis-rules/framework-linting-rules/core-rule-extensions/custom-lint-rule-plugins/custom-lint-rule-definitions/custom-formatting-rules.md) — Enables project-specific code transformations using string-to-string functions within the build script. ([source](https://github.com/diffplug/spotless/blob/main/plugin-gradle/))
- [ESLint](https://awesome-repositories.com/f/development-tools-productivity/configuration-importers/plugin-importers/eslint-import-plugins/formatting-presets/eslint.md) — Applies ESLint styling and auto-fixing to source files via managed configuration. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/npm/EslintFormatterStep.java))
- [Dynamic License Headers](https://awesome-repositories.com/f/development-tools-productivity/dynamic-license-headers.md) — Adds copyright notices to the top of files using dynamic year replacement and git history. ([source](https://github.com/diffplug/spotless/blob/main/plugin-gradle/))
- [External Process Delegation](https://awesome-repositories.com/f/development-tools-productivity/external-process-delegation.md) — Delegates the formatting process to external binaries and system commands on the host OS.
- [Import Organizers](https://awesome-repositories.com/f/development-tools-productivity/import-organizers.md) — Sorts and groups import declarations based on a specified order and custom categories. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/java/ImportOrderStep.java))
- [Wildcard Import Restrictions](https://awesome-repositories.com/f/development-tools-productivity/import-sorters/wildcard-import-restrictions.md) — Detects and flags asterisk-based wildcard import statements to ensure explicit class references. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/java/ForbidWildcardImportsStep.java))
- [Incremental Formatting Optimizations](https://awesome-repositories.com/f/development-tools-productivity/incremental-formatting-optimizations.md) — Reduces execution time by tracking file modification times and skipping unchanged files during the formatting process. ([source](https://github.com/diffplug/spotless#readme))
- [Java Formatters](https://awesome-repositories.com/f/development-tools-productivity/java-formatters.md) — Provides standardized styling for Java source files, including string reflowing and import reordering. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java))
- [JSON Pretty Printers](https://awesome-repositories.com/f/development-tools-productivity/json-pretty-printers.md) — Reorganizes JSON source code into an indented, human-readable layout using the Jackson library. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/json/gson/GsonStep.java))
- [License Header Insertion](https://awesome-repositories.com/f/development-tools-productivity/license-header-insertion.md) — Prefixes source files with a specified license header to ensure organizational legal compliance. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/generic/LicenseHeaderStep.java))
- [Regex Text Transformations](https://awesome-repositories.com/f/development-tools-productivity/regex-text-transformations.md) — Provides the ability to transform source code by identifying and replacing patterns with regular expressions.
- [Scala Formatters](https://awesome-repositories.com/f/development-tools-productivity/scala-formatters.md) — Styles Scala files by executing the scalafmt formatter. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/scala/ScalaFmtStep.java))
- [Shell Script Formatters](https://awesome-repositories.com/f/development-tools-productivity/shell-script-formatters.md) — Standardizes the layout of shell script files using the shfmt formatter. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/shell/ShfmtStep.java))
- [YAML Formatters](https://awesome-repositories.com/f/development-tools-productivity/yaml-formatters.md) — Reformats YAML source files using the Jackson YAMLFactory engine. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/yaml/JacksonYamlStep.java))

### Programming Languages & Runtimes

- [Whitespace Cleaners](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/language-syntax/whitespace-based-block-scoping/whitespace-cleaners.md) — Automatically removes trailing spaces and tabs from the end of lines to maintain clean files. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/generic/TrimTrailingWhitespaceStep.java))
- [C++ Code Formatting](https://awesome-repositories.com/f/programming-languages-runtimes/c-code-formatting.md) — Styles C++ source files by executing a clang-format binary. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/cpp/ClangFormatStep.java))
- [Member Declaration Ordering](https://awesome-repositories.com/f/programming-languages-runtimes/class-member-access/member-declaration-ordering.md) — Organizes class methods and fields into a consistent vertical sequence based on visibility. ([source](https://github.com/diffplug/spotless/blob/main/plugin-maven))
- [Code Mutators](https://awesome-repositories.com/f/programming-languages-runtimes/code-mutators.md) — Rewrites source code using specified mutators to improve consistency and quality. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/java/CleanthatJavaStep.java))
- [Import Restrictions](https://awesome-repositories.com/f/programming-languages-runtimes/import-restrictions.md) — Flags and forbids module import statements to ensure that only explicit imports are utilized. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/java/ForbidModuleImportsStep.java))
- [Python Code Formatters](https://awesome-repositories.com/f/programming-languages-runtimes/python-code-formatters.md) — Applies the Black formatter to Python source files using a specified executable. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/python/BlackStep.java))
- [Source Code Transformation Engines](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-compilers/source-code-templates/source-code-transformation-engines.md) — Modifies source files through regular expressions and JSON patches to enforce structural rules.
- [Unused Import Detection](https://awesome-repositories.com/f/programming-languages-runtimes/unused-import-detection.md) — Automatically deletes import statements that are not referenced within the source code. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/java/RemoveUnusedImportsStep.java))

### Testing & Quality Assurance

- [Style Linting](https://awesome-repositories.com/f/testing-quality-assurance/testing-best-practices-methodologies/quality-assurance-practices/pre-commit-quality-checks/formula-quality-checks/style-linting.md) — Identifies formatting violations and reports style errors as lints for manual correction.
- [JavaScript and TypeScript Formatting](https://awesome-repositories.com/f/testing-quality-assurance/code-quality-review/code-quality-tools/formatting-and-linting-pipelines/javascript-and-typescript-toolchains/javascript-and-typescript-formatting.md) — Styles JavaScript, TypeScript, CSS, and JSON files by delegating to the Biome executable. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/biome/BiomeStep.java))
- [Formatting Verification](https://awesome-repositories.com/f/testing-quality-assurance/formatting-verification.md) — Compares source files against expected formatted output to verify style compliance without modifying files. ([source](https://github.com/diffplug/spotless/blob/main/PADDEDCELL.md))

### Part of an Awesome List

- [Kotlin Formatters](https://awesome-repositories.com/f/awesome-lists/devtools/code-formatting/kotlin-formatters.md) — Applies ktfmt to Kotlin source files to ensure consistent styling and trailing comma usage. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java))
- [Markdown Formatting](https://awesome-repositories.com/f/awesome-lists/devtools/linting-and-formatting/markdown-formatting.md) — Standardizes the layout of Markdown files using the flexmark-java engine. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/markdown/FlexmarkStep.java))
- [Regex Pattern Matching](https://awesome-repositories.com/f/awesome-lists/devtools/regex-and-pattern-matching/regex-pattern-matching.md) — Identifies specific text patterns in source files using regular expressions to report linting errors. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/generic/ReplaceRegexStep.java))
- [Regex Search and Replace](https://awesome-repositories.com/f/awesome-lists/devtools/regex-and-pattern-matching/regex-pattern-matching/batch-text-editors/regex-search-and-replace.md) — Transforms source code by identifying specific patterns with regular expressions and replacing them with defined strings.
- [Development Tooling](https://awesome-repositories.com/f/awesome-lists/devtools/development-tooling.md) — Tool for keeping code formatting consistent.
- [Development Utilities](https://awesome-repositories.com/f/awesome-lists/devtools/development-utilities.md) — Automates code formatting and style enforcement.

### Business & Productivity Software

- [Incremental Formatting](https://awesome-repositories.com/f/business-productivity-software/workflow-execution-engines/incremental-execution/incremental-formatting.md) — Optimizes execution time by tracking file modification timestamps to skip files that have not changed.

### Data & Databases

- [JSON Patching](https://awesome-repositories.com/f/data-databases/json-patching.md) — Implements standard-compliant JSON patching to ensure specific structural requirements in JSON files. ([source](https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/json/JsonPatchStep.java))

### DevOps & Infrastructure

- [Shared Formatting Configurations](https://awesome-repositories.com/f/devops-infrastructure/centralized-configuration-management/shared-formatting-configurations.md) — Allows formatting rules to be distributed and loaded across multiple projects via remote artifacts. ([source](https://github.com/diffplug/spotless/blob/main/plugin-maven))
- [Configuration Distribution and Sharing](https://awesome-repositories.com/f/devops-infrastructure/configuration-management/configuration-distribution-and-sharing.md) — Distributes and loads consistent formatting rules across multiple projects via remote artifacts.

### Security & Cryptography

- [Style Compliance Reporting](https://awesome-repositories.com/f/security-cryptography/compliance-verification-tools/style-compliance-reporting.md) — Reports differences between the current code and the expected format to detect style violations. ([source](https://github.com/diffplug/spotless/blob/main/README.md))

### Software Engineering & Architecture

- [Automated License Header Injection](https://awesome-repositories.com/f/software-engineering-architecture/automated-license-header-injection.md) — Inserts and updates standardized copyright notices and license headers using git history for accuracy.
- [Coding Best Practices](https://awesome-repositories.com/f/software-engineering-architecture/coding-best-practices.md) — Applies modernization and security rules to ensure source code adheres to consistent language standards. ([source](https://github.com/diffplug/spotless/blob/main/rewrite.yml))
- [Java Coding Standards](https://awesome-repositories.com/f/software-engineering-architecture/dotnet-code-style-standards/java-coding-standards.md) — Applies the Eclipse JDT formatter to ensure a consistent coding style for Java source code. ([source](https://github.com/diffplug/spotless/blob/main/lib-extra/src/main/java/com/diffplug/spotless/extra/java/EclipseJdtFormatterStep.java))
- [Embedded Language Formatters](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/plugin-architectures/domain-specific/language-support-definitions/language-parsing-rules/language-specific-formatting-overrides/embedded-language-formatters.md) — Styles nested code snippets using language-specific rules and delimiters for multi-language files. ([source](https://github.com/diffplug/spotless/blob/main/plugin-gradle))

### Web Development

- [Web Code Formatting Standards](https://awesome-repositories.com/f/web-development/web-code-formatting-standards.md) — Styles CSS, HTML, JS, JSON, and XML files using the Eclipse WTP formatter. ([source](https://github.com/diffplug/spotless/blob/main/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java))
