square

square/kotlinpoet

Kotlin Apache-2.0 Dev Tools

A Kotlin API for generating .kt source files.

4.1k stars
312 forks
active
GitHub

4.1k

Stars

312

Forks

68

Open issues

30

Contributors

2.3.0 27 Mar 2026

AI Analysis

KotlinPoet is a Kotlin and Java API for programmatically generating .kt source files, serving developers who build code generators, annotation processors, and metaprogramming tools. It is purpose-built for the code-generation niche and is most valuable for library authors, framework developers, and tooling engineers rather than general application developers. Mainstream adoption within the JVM ecosystem but specialized in function.

Dev Tools Developer Tool Discovery value: 3/10
Documentation 7/10
Activity 9/10
Community 9/10
Code quality 5/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

code-generation kotlin-jvm metaprogramming source-codegen javapoet-kotlin
Actively maintained Popular Niche/specialized use case Well documented Production ready
Deep Analysis · Based on README and public signals
2w ago

Kotlin code generation library for programmatic .kt file creation

KotlinPoet is a Java and Kotlin API that enables programmatic generation of Kotlin source code files. Built by Square in 2017, it targets developers building code generators, annotation processors, and metaprogramming tools. Adoption appears concentrated among library authors and framework builders rather than end-application developers. The project is actively maintained with steady but modest growth, suggesting established, stable usage within a specialized niche.

Origin

KotlinPoet originated at Square in 2017 as a Kotlin equivalent to JavaPoet, Square's earlier Java code generation library. It emerged during Kotlin's rapid adoption period and has evolved alongside Kotlin's ecosystem maturation, particularly with the rise of annotation processing and code generation patterns in Android and JVM development.

Growth

The repository shows consistent but gradual growth (4,142 stars over 9 years, 1 star in the last week). Growth pattern suggests adoption plateaued after reaching libraries and frameworks that depend on it—not a viral/trending project, but steady integration into build pipelines. The relatively stable star count despite 311 forks indicates deep, narrow adoption rather than broad awareness.

In production

Adoption not verified through provided metadata. README lacks case studies, known users list, or quantified production deployment evidence. However, the existence of 311 forks and 4,142 stars over 9 years, combined with Square's reputation, suggests real but undocumented usage. The stable star trajectory suggests integration into established libraries rather than new projects.

Code analysis
Architecture

Based on README, KotlinPoet appears to provide a fluent API for constructing Kotlin language constructs (functions, classes, properties, etc.) programmatically. Likely uses builder/DSL patterns typical of code generation libraries. README does not detail architecture beyond high-level positioning.

Tests

Not documented in README. No visibility into test suite size, coverage metrics, or testing strategy from provided metadata.

Maintenance

Last push on 2026-06-24 (2 days before analysis date) indicates active maintenance. Project is not abandoned. However, sparse growth metrics (1 star/week) and lack of detailed release notes in README suggest this is a stable, mature project receiving incremental updates rather than rapid feature development or optimization cycles.

Honest verdict

ADOPT IF: you are building code generators, annotation processors, or metaprogramming tools that emit Kotlin code and need type-safe, maintainable generation APIs. AVOID IF: you need a general-purpose code templating system, require cutting-edge performance optimizations, or need extensive documentation and tutorials beyond the README. MONITOR IF: you are evaluating annotation processing strategies—KSP is ascendant in newer Kotlin projects, and KotlinPoet's relevance may shift as KSP adoption grows.

Independent dimensions

Mainstream potential

3/10

Technical importance

7/10

Adoption evidence

4/10

Risks
  • KSP adoption may reduce demand for lower-level code generation libraries; KotlinPoet may become a dependency rather than a first-choice tool.
  • Sparse documentation and examples (README is minimal) may increase adoption friction for new users unfamiliar with code generation patterns.
  • Slow growth rate and lack of visible community could indicate difficulty attracting contributors or users learning the tool independently.
  • No evidence of Kotlin language feature parity—likelihood that library lags Kotlin spec evolution is unverified.
  • Maintenance by Square but no evidence of dedicated team or public roadmap; risk of becoming legacy if priorities shift.
Prediction

KotlinPoet will likely remain a stable, foundational library for Kotlin code generation but is unlikely to grow beyond its current niche of framework and tool builders. It may gradually become less visible as KSP-based tools emerge as the canonical pattern, but it will probably persist as a lower-level utility within the broader annotation processing ecosystem.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

Kotlin
99.4%
Java
0.6%

Information

Language
Kotlin
License
Apache-2.0
Last updated
13h ago
Created
114mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Similar repos

google

google/ksp

Kotlin Symbol Processing (KSP) is an official Kotlin compiler plugin API for...

3.5k Kotlin Dev Tools
Kotlin

Kotlin/dokka

Dokka is an API documentation engine for Kotlin that generates reference...

3.8k Kotlin Dev Tools
JetBrains

JetBrains/kotlin

Kotlin is a statically-typed, multiplatform programming language developed and...

53.1k Kotlin Dev Tools
Kotlin

Kotlin/kotlinx-kover

Kover is a JetBrains-maintained code coverage toolset specifically for Kotlin...

1.6k Kotlin Dev Tools
square

square/moshi

Moshi is a modern JSON serialization/deserialization library for Kotlin and...

10.1k Kotlin Dev Tools
vs. alternatives
google/ksp

KSP (Kotlin Symbol Processing) is a newer (post-2020) annotation processing framework that can perform code generation. Differs in scope: KSP is a compiler plugin framework, while KotlinPoet is a code-generation utility library. KotlinPoet is often used *within* KSP-based processors.

JavaPoet (Square)

KotlinPoet's spiritual predecessor for Java. Serves the same niche for Java code generation. KotlinPoet is the Kotlin-native equivalent and has likely achieved parity or better integration with Kotlin tooling.

Kotlin/dokka

Dokka generates documentation, not code. Different problem space. Not a direct competitor, though both operate in Kotlin ecosystem tooling.

Manual code generation or string templates

KotlinPoet competes against hand-written or template-based code generation. Offers type safety, IDE support, and maintainability advantages for complex generation scenarios.