Back to browse
GitHub Repository

A streaming-capable markdown parser, written in TypeScript

10 starsTypeScript

Parse LLM Markdown streams incrementally on the server or client

by nayajunimesh·May 14, 2026·4 points·1 comment

AI Analysis

●●SolidSolve My ProblemShip It

Incremental AST parsing beats full re-renders for long LLM markdown streams.

Strengths
  • Buffers incomplete blocks to avoid re-parsing the whole document on every chunk.
  • Typed AST output follows CommonMark spec while supporting incremental updates.
  • Experimental open node preview allows animating unfinished blocks safely.
Weaknesses
  • Only eight GitHub stars suggests limited real-world battle testing so far.
  • Incremental parsing edge cases around nested lists could introduce rendering bugs.
Target Audience

Frontend engineers building AI chat interfaces

Similar To

micromark · marked · remark

Post Description

Most AI chat applications (such as ChatGPT or Claude) stream their responses to the client as markdown text. As each new chunk of text arrives, the front end typically re-parses the entire markdown document to render the updated message. This works, but it can quickly slow down the UI for long responses.

I’ve been obsessing over ways to make this more efficient, so I wrote a markdown parser that can parse streaming markdown (semi) incrementally. Instead of re-processing the whole document each time, it only parses what’s new, processing each line only once. Block‑level nodes are buffered until they’re complete (for example, once a paragraph is done and won’t be extended by more text). This also makes parsing the markdown on server possible. The main demo does exactly that. Additionally, animating markdown blocks becomes much simpler and efficient, as a result.

Here’s a demo if you’d like to see it in action: https://markdownparser.vercel.app/experimental

Feel free to type 'Render a table with 10 rows' to see each table row animate in.

I’ve spent a lot of time thinking about this problem, so if you’re working on similar issues, I'd love to chat.

Similar Projects

AI/ML●●Solid

LLM Wiki Compiler Inspired by Karpathy

Two-phase pipeline eliminates order-dependence before writing any wiki pages.

Big BrainNiche Gem
ethanjoffe
772mo ago