Automatic imports
Reference a qualified type or function. Prosa.kt collects, sorts, and deduplicates its imports, and uses qualified names when symbols collide.
Prosa.kt · Kotlin source generation
Define classes, functions, and expressions in pure Kotlin. Prosa.kt handles the imports, escaping, and formatting.
implementation("com.alexstyl:prosakt:0.1.1")Prosa.kt DSL
ktFile { ktValue("message") { initializer { literal("Hello, Kotlin!") } }}Generated Kotlin
val message = "Hello, Kotlin!"Interactive playground
Choose an example and edit the DSL. The generated Kotlin updates as you type.
Loading playground…
Built into the DSL
Use Kotlin builders to define declarations and expressions. Prosa.kt turns them into source text with imports, escaped literals, and consistent formatting.
Reference a qualified type or function. Prosa.kt collects, sorts, and deduplicates its imports, and uses qualified names when symbols collide.
Pass strings and numbers to literal(). Quotes, backslashes, and dollar signs are escaped for the generated Kotlin.
Get consistent indentation and automatic line wrapping for structured expressions. Keep generated source readable when reviewing or debugging it.
Getting started
Add Prosa.kt to your JVM project or Kotlin Multiplatform source set, then call ktFile to generate source.
With mavenCentral() configured, add this to your dependencies.
implementation("com.alexstyl:prosakt:0.1.1")import com.alexstyl.prosakt.ktFile
val source = ktFile { ktValue("message") { initializer { literal("Hello from Prosa.kt") } }}ktFile returns a string. Save it to a .kt file or pass it to your existing generation pipeline.
Using Prosa.kt
All of them. Prosa.kt is written in pure Kotlin and targets JVM, JavaScript, WebAssembly, and Kotlin/Native. Add it to the source set that runs your generator. See the setup for your project.
Prosa.kt returns Kotlin source text. Your project handles writing files, registering generated sources, and compilation. The DSL checks structural mistakes, but it does not type-check the generated program.
Yes. In your Kotlin project, the builder is ordinary Kotlin: use loops, conditions, and your own functions to drive generation. This browser playground supports a smaller set of builder calls and literal values.
Prosa.kt is open source under the MIT license. You can use it in personal and commercial projects.Browse the source on GitHub.
Add Prosa.kt to your project
Follow the setup guide and generate your first Kotlin file.