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.