What is KStateMachine?
KStateMachine lets you model complex application logic as
a finite state machine
or statechart using an expressive Kotlin DSL.
It runs on every Kotlin Multiplatform target, integrates seamlessly with Kotlin Coroutines, and has zero mandatory
dependencies.
🚀 Quick Start
Animated traffic light
Output
🔴 Red — stop!
→ switching…
leaving red
🟡 Yellow — get ready
🟢 Green — go!
✅ Done
✨ Key Features
Integration
State management
Tooling
🔌 IntelliJ IDEA Plugin
KStateMachine Visual is an
IntelliJ IDEA plugin that visualizes and navigates your state machines straight from Kotlin source —
no runtime required.
- Tree view with specialized icons for every state type (initial, final, choice, history, data, parallel)
- Bidirectional navigation between the editor and the tree view
- Live PlantUML diagram — rendered inline with debounced real-time updates as you type (no Graphviz needed)
- Export as SVG or raw PlantUML source
- Static analysis — resolves the full DSL tree including states inside conditional branches that runtime export
misses
Install: Settings → Plugins → Marketplace → search KStateMachine Visual
See the plugin documentation page
for the full feature reference and manual install instructions.
📄 Documentation
[!IMPORTANT]
Full documentation lives at
kstatemachine.github.io/kstatemachine
KDoc for every class:
kstatemachine.github.io/kstatemachine/kdoc
❤️ Sponsors
If KStateMachine saves you time, please consider supporting the project:
- ⭐ Star this repo — it helps others discover it
- ❤️ GitHub Sponsors — one-time or recurring donations
- 💛 Open Collective — transparent team funding
🧪 Samples
Full app samples and 20+ runnable focused code samples are listed on the
Samples page in the documentation.
✍️ Publications
💾 Install
KStateMachine is published to Maven Central and JitPack.
dependencies {
implementation("io.github.nsk90:kstatemachine:<Tag>")
implementation("io.github.nsk90:kstatemachine-coroutines:<Tag>")
implementation("io.github.nsk90:kstatemachine-serialization:<Tag>")
}
Replace <Tag> with the current version shown in the Maven Central badge above.
See the full install guide for Gradle Kotlin DSL,
Groovy DSL, and JitPack variants.
🏗️ Build
./gradlew build
./gradlew :tests:jvmTest
Or open in IntelliJ IDEA and run from there.
🤝 Contribution
The library is in stable phase — but feature proposals and pull requests are welcome!
Please read CONTRIBUTING.md before submitting.
🙋 Support
When asking on other platforms, include a link to this repo or use the #kstatemachine tag.
🗺️ Roadmap
🏅 Thanks to supporters

🖋️ License
Licensed under the permissive Boost Software License.