StealThis .dev

Streaming Markdown

A streaming markdown renderer that types an AI-style response token-by-token behind a blinking cursor while live-parsing headings, lists, bold, tables, and fenced code blocks the instant they complete. Code blocks gain a one-tap copy button, and start, stop, and replay controls plus a speed dial let you scrub the token cadence from a slow reveal to a firehose.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

Streaming Markdown recreates the feel of an LLM answer landing in a chat window: text arrives a few characters at a time behind a soft blinking caret, and a small self-contained markdown parser re-renders the buffer on every tick so headings, bold spans, ordered and unordered lists, blockquotes, tables, inline code, and fenced code blocks snap into their formatted shape the moment their syntax closes. Nothing is pre-rendered — you watch structure crystallize out of a raw token stream exactly like a real completion.

The toolbar drives the whole experience. Start begins the stream, Stop pauses it mid-flight, and Replay clears the canvas and runs it again from the first token. A speed control switches between slow, normal, and turbo cadences, and a live token counter plus a status pill tell you whether the model is idle, streaming, or done. Every fenced code block renders with a language label and a Copy button that writes to the clipboard and flips to a confirmation state.

Under the hood the reveal loop is driven by requestAnimationFrame with an accumulator so the cadence stays smooth and frame-rate independent, while navigator.clipboard.writeText powers the copy buttons with a graceful execCommand fallback for older or insecure contexts. The parser is a compact hand-written tokenizer — no libraries, no build step — so the entire component is drop-in and dependency-free.