A set of Java annotation-processing code generators, including AutoValue, AutoFactory, AutoService and Common helpers.
square/kotlinpoet
A Kotlin and Java API for programmatically generating Kotlin .kt source files.
- Stars
- 4,164
- Forks
- 318
- Open issues
- 68
- Last commit
- 4 days ago
What is it?
KotlinPoet is a library that lets developers build Kotlin source files from code instead of writing text templates by hand. It is usable from both Kotlin and Java, and it is the Kotlin counterpart to JavaPoet, which serves the same purpose for Java.
The library is aimed at annotation processors, build plugins and other code generators that need to emit correct Kotlin code. Generated output is produced through a builder-style API that handles the bookkeeping of types, imports and formatting for the caller.
The project is maintained by Square and published under the Apache-2.0 license, with documentation hosted on its project site.
Key features
- 01Generates .kt source files from a programmatic, builder-style API.
- 02Can be called from both Kotlin and Java code.
- 03Handles type references and import statements in generated output.
- 04Serves as the Kotlin counterpart to JavaPoet.
Use cases
- Writing annotation processors that emit Kotlin classes or functions.
- Building Gradle or Maven plugins that generate Kotlin boilerplate.
- Producing Kotlin code from schemas or other metadata at build time.
Quick start
- 1
Visit the project documentation at the official site
Things to know
- The README is minimal and gives no installation command or usage example.
Topics
FAQ
- What is kotlinpoet?
- A Kotlin and Java API for programmatically generating Kotlin .kt source files. KotlinPoet is a library that lets developers build Kotlin source files from code instead of writing text templates by hand. It is usable from both Kotlin and Java, and it is the Kotlin counterpart to JavaPoet, which serves the same purpose for Java.
- Is kotlinpoet free to use? What license does it have?
- kotlinpoet is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is kotlinpoet still maintained?
- Actively maintained. The last commit to kotlinpoet was on Nov 2, 2026.
- What can I use kotlinpoet for?
- Writing annotation processors that emit Kotlin classes or functions. Building Gradle or Maven plugins that generate Kotlin boilerplate. Producing Kotlin code from schemas or other metadata at build time.
- How do I install kotlinpoet?
- Visit the project documentation at the official site
- Where can I get kotlinpoet?
- The source code and installation instructions are on GitHub: https://github.com/square/kotlinpoet
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Java library that plugs into editors and build tools to generate boilerplate such as getters, equals, builders and logging fields via annotations.
An Android IDE that runs on the phone itself, letting you build Android apps without a laptop or Internet connection.
A free, open-source C/C++ package manager from Microsoft for installing and building libraries on Windows, macOS, and Linux.
A JavaScript parser, mangler and compressor toolkit for ES6+ code, a maintained fork of uglify-es for minifying modern JavaScript.
A monorepo of reusable build, lint, and API tooling for large-scale TypeScript projects, centered on the Rush and Heft build systems.