# ktlint/ktlint

**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/ktlint-ktlint).**

6,717 stars · 525 forks · Kotlin · MIT

## Links

- GitHub: https://github.com/ktlint/ktlint
- Homepage: https://ktlint.github.io/ktlint/
- awesome-repositories: https://awesome-repositories.com/repository/ktlint-ktlint.md

## Topics

`kotlin` `lint` `linter`

## Description

ktlint is a linter and code formatter for Kotlin that checks source files against a built-in set of style rules and automatically rewrites them to match those rules. It operates by walking the Kotlin abstract syntax tree, detecting violations, and applying transformations directly at the node level before regenerating the source code from the modified tree.

The project ships a curated default rule set that requires no configuration to enforce consistent formatting, and provides a command-line interface for running linting and formatting in batch mode. Its rule-set-based plugin architecture allows loading independent rule sets as plugins, each defining their own lint checks and formatting actions, while a reporter abstraction layer outputs results through pluggable reporters in plain text, JSON, or other formats.

Users can extend ktlint with custom rule sets and reporters to add or replace linting and formatting behavior, enabling enforcement of project-specific coding standards. The project covers both linting—checking code against built-in style rules and reporting violations—and automatic formatting of Kotlin source files to match those rules without manual effort.

## Tags

### Part of an Awesome List

- [Kotlin Formatters](https://awesome-repositories.com/f/awesome-lists/devtools/code-formatting/kotlin-formatters.md) — Formats Kotlin source files to match built-in style rules automatically. ([source](https://cdn.jsdelivr.net/gh/ktlint/ktlint@master/README.md))
- [Kotlin Linters](https://awesome-repositories.com/f/awesome-lists/devtools/code-quality-linting/kotlin-linters.md) — Checks Kotlin source files against built-in style rules and reports violations without configuration. ([source](https://cdn.jsdelivr.net/gh/ktlint/ktlint@master/README.md))
- [Linters](https://awesome-repositories.com/f/awesome-lists/devtools/kotlin/linters.md) — Checks Kotlin code against built-in style rules to catch violations and enforce conventions.

### Development Tools & Productivity

- [Source Code Rewriting](https://awesome-repositories.com/f/development-tools-productivity/ast-transformation-tools/ast-to-source-conversion/source-code-rewriting.md) — Transforms the AST directly to fix violations, then regenerates source code from the modified tree.
- [Custom Lint Rule Plugins](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.md) — Loads user-defined rule sets and reporters to add or replace linting and formatting behavior. ([source](https://cdn.jsdelivr.net/gh/ktlint/ktlint@master/README.md))
- [Command Line Interfaces](https://awesome-repositories.com/f/development-tools-productivity/command-line-interfaces.md) — Provides a CLI that accepts file paths and options to run linting and formatting in batch mode.

### Software Engineering & Architecture

- [Configuration-Free Rule Sets](https://awesome-repositories.com/f/software-engineering-architecture/configuration-free-rule-sets.md) — Ships a curated collection of style rules that require no configuration to enforce consistent formatting.
- [Plugin-Based Architectures](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/plugin-module-systems/modular-plugin-architectures/plugin-based-architectures/plugin-based-architectures.md) — Loads independent rule sets as plugins that each define their own lint checks and formatting actions.
- [Syntax Traversal](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/syntax-traversal.md) — Walks the Kotlin abstract syntax tree to detect style violations and apply node-level transformations.
- [Custom Rule Development](https://awesome-repositories.com/f/software-engineering-architecture/custom-rule-development.md) — Extends the linter with user-defined rule sets and reporters to enforce project-specific coding standards.
- [Violation Reporters](https://awesome-repositories.com/f/software-engineering-architecture/violation-reporters.md) — Outputs results through pluggable reporters that format violations as plain text, JSON, or other formats.
