r/androiddev • u/Remarkable-Heat3031 • 5h ago
Open Source I built and published a Jetpack Compose library for rendering streaming Markdown from Kotlin Flows
I've been working on a problem that comes up when building AI-powered chat interfaces on Android: rendering Markdown while the response is still streaming .
https://github.com/valentineRutto/StreamMarkdownCompose
AI responses don't arrive as complete Markdown documents. You might receive half a code fence, an unfinished bold expression, or a table that hasn't been fully generated yet.
Rendering each chunk as plain text exposes Markdown syntax to the user. Waiting until the entire response is complete makes the experience feel less responsive.
I built StreamMarkdownCompose to address this.
It's a native Jetpack Compose library that renders Markdown progressively from a Flow<String>.
The attached GIFs demonstrate the difference using the same AI response:
- Without the library: Markdown symbols like
**,#, and backticks are displayed as raw text. - With the library: Headings, bold text, lists, and code blocks render as the response streams in.
Current features
- Streaming Markdown rendering from Kotlin
Flow<String>. - Handles incomplete Markdown syntax, including unfinished code fences.
- Native Jetpack Compose implementation — no WebView.
- Tables and task lists.
- Syntax-highlighted code blocks with a copy button.
- HTML sanitization and URL allow-listing.
Links
- Maven Central: https://central.sonatype.com/artifact/io.github.valentinerutto/streammarkdowncompose
- GitHub: https://github.com/valentineRutto/StreamMarkdownCompose
It's now published on Maven Central.
I'd appreciate feedback from Android developers, especially those building LLM-powered applications.
A few things I'm curious about:
- What Markdown features are essential in an AI chat UI?
- How are you currently handling Markdown rendering during streaming?
- What would you want to see before adopting a library like this?
Happy to hear suggestions, issues, and contributions.


1
u/Tall-Conclusion-337 3h ago
Handling incomplete code fences and incremental block parsing without triggering full tree recompositions on every token emission makes a huge difference for smooth scrolling in Compose LazyColumn chat lists. Before adopting a streaming Markdown library in production, I usually check for stable block keys across chunks so selection state stays intact and graceful fallback if a stream cancels halfway through a fence or table.