r/androiddev • • 2d 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

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.

13 Upvotes

3 comments sorted by

3

u/RJ_Satyadev 1d ago

Feedback nothing related to your library, but maybe you can improve on the demo app UI? If you want to spend time there? Maybe Mayerial 3 Expressive UI?

0

u/[deleted] 2d ago

[removed] — view removed comment

1

u/androiddev-ModTeam 2d ago

Use your own voice when writing. Posts and comments which appear to be generated, including those with excessive flourish, gushing or emojis, will be removed.