ktlint

Kotlin code formatter and linter from Pinterest — zero-configuration (no .editorconfig required for defaults) formatter that enforces the Kotlin official style guide. ktlint provides: auto-formatting (ktlint --format), lint checking (ktlint check), Gradle integration (ktlintCheck/ktlintFormat tasks), IntelliJ/Android Studio plugin, and EditorConfig support for custom rules. Works as a complementary tool to Detekt — ktlint handles formatting (indentation, spaces, blank lines, trailing whitespace) while Detekt handles code smells and complexity. Part of most Android/Kotlin CI pipelines.

Evaluated Mar 06, 2026 (0d ago) v1.x
Homepage ↗ Repo ↗ Developer Tools kotlin formatting linting style android gradle pinterest code-quality
⚙ Agent Friendliness
70
/ 100
Can an agent use this?
🔒 Security
96
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
90
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
98
Auth Strength
98
Scope Granularity
95
Dep. Hygiene
92
Secret Handling
95

Code formatting tool — no security concerns. No network access during formatting. Consistent formatting indirectly improves security by making code easier to review.

⚡ Reliability

Uptime/SLA
90
Version Stability
85
Breaking Changes
75
Error Recovery
92
AF Security Reliability

Best When

You want zero-effort, zero-configuration Kotlin code formatting enforcement in CI — ktlint's defaults match official Kotlin style guide and require no team debate on formatting.

Avoid When

You need code smell detection (use Detekt instead or in addition), you have complex custom formatting rules not supported by ktlint's .editorconfig options, or you're in a non-Kotlin project.

Use Cases

  • Enforce consistent Kotlin code formatting in agent codebase using ktlint Gradle tasks — ktlintCheck in CI fails PRs with formatting issues; ktlintFormat auto-fixes locally
  • Standardize Kotlin code style across agent project team using ktlint's zero-configuration defaults — no committee debate on formatting rules; ktlint enforces official Kotlin style guide
  • Pre-commit hook for automatic agent code formatting — git hook runs ktlintFormat before commits to prevent formatting PRs from polluting git history
  • Customize agent project formatting rules with .editorconfig — override specific ktlint rules (max line length, trailing commas) while keeping ktlint's default enforcement
  • Generate SARIF output for GitHub Code Scanning integration — ktlint --reporter=sarif for GitHub Advanced Security formatting findings display in PRs

Not For

  • Code smell detection beyond formatting — use Detekt for complexity, code smells, and logic issues; ktlint focuses on formatting not logic
  • Non-Kotlin files — ktlint is Kotlin-only; use Prettier (JS/TS), Black (Python), or gofmt (Go) for other languages in polyglot repositories
  • Complex custom rule enforcement — ktlint custom rule creation is possible but complex; Detekt custom rules are easier to write for business-specific code quality rules

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Code formatting tool — no auth concepts.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

ktlint is MIT licensed, maintained by Pinterest and community. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • ktlint 1.x vs 0.x breaking changes — ktlint 1.0 changed rule IDs and EditorConfig property names; .editorconfig files configured for 0.x may silently not apply to ktlint 1.x; update rule names after upgrading
  • Android Studio/IntelliJ auto-format conflict — IDE's Kotlin formatter may apply different formatting than ktlint; configure IDE to use ktlint via ktlint-intellij-plugin or Spotless IDE integration; misaligned formatting causes constant ktlintCheck failures
  • Gradle task configuration varies by plugin — jlleitschuh/ktlint-gradle plugin and Spotless both support ktlint; configuration syntax differs; follow the specific plugin's docs; mixing documentation from different plugins causes misconfigured tasks
  • Generated Kotlin files should be excluded — Room, KSP, and kapt-generated .kt files in build/ directory should be excluded from ktlint check; add build/ to .editorconfig ktlint exclusion or Gradle task source configuration
  • Multi-module Gradle projects need per-module configuration — ktlint Gradle plugin applies to each module separately; root project configuration doesn't auto-apply to subprojects without explicit subprojects { } block
  • Pre-commit hook with Husky vs manual setup — pre-commit ktlint hooks require staged-file filtering (ktlintFormat only changed files); formatting all files in pre-commit is too slow; use lint-staged pattern or custom git hook script

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for ktlint.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered