# kotlinpoet

> A Kotlin API for generating .kt source files.

- **URL**: https://www.freshcrate.ai/projects/kotlinpoet
- **Author**: square
- **Category**: Uncategorized
- **Latest version**: `2.3.0` (2026-03-27)
- **License**: Apache-2.0
- **Source**: https://github.com/square/kotlinpoet
- **Homepage**: https://square.github.io/kotlinpoet/
- **Language**: Kotlin
- **GitHub**: 4,131 stars, 307 forks
- **Registry**: github
- **Tags**: `code-generation`, `javapoet`, `kotlin`

## Description

A Kotlin API for generating .kt source files.

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `2.3.0` | 2026-03-27 | Medium | Thanks to @haruue, @hfhbd, @yz4230, @mina-jaff, @BoD, @RaoPrashanth for contributing to this release.  * New: Kotlin 2.3.20. * New: KSP 2.3.6. * New: Support for defining type aliases inside other types. (#2167) * New: Add `TypeName.annotated()` convenience API for adding annotations to types. (#2281) * New: Add `FileSpec.addImport(MemberName)` to explicitly import a member. (#2198) * New: Add `NameAllocator.contains` to check if a given tag is already allocated. (#2160) * New: `:interop |
| `2.2.0` | 2025-05-16 | Low | Thanks to @IRus for contributing to this release.   * New: Kotlin 2.1.21.  * New: KSP 2.1.21-2.0.1.  * New: Add support for context parameters. (#2112)  * New: Eliminate Guava dependency. (#2110)  * New: Migrate to Dokka plugin V2. (#2113) |
| `2.1.0` | 2025-02-25 | Low | Thanks to @ForteScarlet, @TrevorSStone, @RaoPrashanth, @damianw, @ansehoon1999, @TheMrMilchmann for contributing to this release.   * New: Kotlin 2.1.10.  * New: KSP 2.1.10-1.0.30.  * Fix: Support delegates on anonymous classes. (#2034)  * Fix: Prevent aliased imports from colliding with existing imports. (#2052)  * Fix: `TypeName.MUTABLE_MAP_ENTRY` now correctly uses the `MutableEntry` nested class name. (#2061)  * Fix: Use the same aliased import for both the nullable and non-nullable v |
| `2.0.0` | 2024-10-23 | Low | Thanks to @brokenhappy, @tajobe, @niyajali, @ForteScarlet for contributing to this release.  This release is source- and binary-compatible with KotlinPoet 1.x.  The most important behavior change in this release is that spaces in generated code don't wrap by default anymore.  KotlinPoet 1.x used to replace space characters with newline characters whenever a given line of code exceeded the length limit. This usually led to better code formatting, but could also lead to compilation errors in |
| `1.18.1` | 2024-07-15 | Low | Thanks to @mitasov-ra for contributing to this release.  - Fix: Workaround for [KT-18706](https://youtrack.jetbrains.com/issue/KT-18706): KotlinPoet now generates import aliases without backticks (#1920).  ```kotlin // before, doesn't compile due to KT-18706 import com.example.one.`$Foo` as `One$Foo` import com.example.two.`$Foo` as `Two$Foo`  // now, compiles import com.example.one.`$Foo` as One__Foo import com.example.two.`$Foo` as Two__Foo ``` |
| `1.18.0` | 2024-07-05 | Low | Thanks to @DanielGronau for contributing to this release.   * New: Kotlin 2.0.0.  * New: KSP 2.0.0-1.0.22.  * New: Promote `kotlinpoet-metadata` out of preview to stable.  * New: Migrate `kotlinpoet-metadata` to stable `org.jetbrains.kotlin:kotlin-metadata-jvm` artifact for Metadata parsing.  * New: Make enum entry references in `KSAnnotation.toAnnotationSpec()` and `KSClassDeclaration.toClassName()` more robust.  * Fix: Don't expand typealiases of function types to `LambdaTypeName`s in ` |
| `1.17.0` | 2024-05-24 | Low | Thanks to @jisungbin, @hfhbd, @evant, @sgjesse, @sebek64 for contributing to this release.  - Change: kotlinx-metadata 0.9.0. Note that the `KotlinClassMetadata.read` is deprecated in 0.9.0 and replaced with `readStrict` (#1830).   - Note: we now also provide `lenient` parameters to map to the underlying `readStrict()` and `readLenient()` calls (#1766).   - We have also removed various `Class`/`TypeElement`/`Metadata`-to-`KmClass` APIs from the public API, as these are trivial to write now w |
| `1.16.0` | 2024-01-18 | Low | Thanks to @drawers, @rickclephas for contributing to this release.  - New: Kotlin 1.9.22. - New: KSP 1.9.22-1.0.16. - New: Add `NameAllocator` API to control keyword pre-allocation (#1803). - Fix: Fix issue with missing suspend modifier in `KSTypeReference.toTypeName` (#1793). - Fix: Honour same-package import aliases (#1794). - Fix: Always include parameter docs in the type header (#1800). |
| `1.15.3` | 2023-12-04 | Low | Thanks to @gabrielittner for contributing to this release.  * Fix: Fix nullability of lambdas in `KSTypeReference.toTypeName` (#1756). |
| `1.15.2` | 2023-11-30 | Low | Thanks to @evant for contributing to this release.   * New: Kotlin 1.9.21.  * New: KSP 1.9.21-1.0.15.  * New: KSP: more accurately represent function types (#1742). |

## Citation

- HTML: https://www.freshcrate.ai/projects/kotlinpoet
- Markdown: https://www.freshcrate.ai/projects/kotlinpoet.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/kotlinpoet/deps

_Generated by freshcrate.ai. Indexes github releases for AI-agent ecosystem packages._
