microsoft/SwiftStreamingMarkdown

A performant markdown library for iOS & macOS that supports streaming

What it solves

SwiftStreamingMarkdown is designed for chat-style user interfaces where text is streamed from a Large Language Model (LLM) in real-time. Traditional Markdown renderers often cause UI stalls or jarring transitions when updating the view as new text arrives; this library provides smooth, high-performance streaming transitions and optimized rendering to maintain a fluid user experience on iOS and macOS.

How it works

The library provides a specialized StreamedMarkdownView that consumes a StreamedMarkdownSource. Instead of re-rendering the entire document from scratch, it incrementally parses and renders snapshots of the Markdown source as they arrive, minimizing main-thread work to prevent UI lag. It targets a subset of CommonMark and GitHub-flavored Markdown specifically tailored to the types of responses LLMs typically generate.

Who it’s for

Developers building AI chat applications for iOS and macOS who need a professional, polished streaming text experience with support for complex elements like LaTeX math and citations.

Highlights

  • Smooth Streaming: Built-in animations for newly received text to avoid jarring updates.
  • LLM-Optimized: Specifically supports the syntax LLMs commonly emit, including tables, fenced code blocks, and task lists.
  • Advanced Rendering: Native support for inline and block LaTeX math rendering.
  • Source Grounding: Includes a dedicated UI for inline citation pills to support source-grounded LLM responses.
  • Customizable: Highly configurable typography and theming via MarkdownRenderConfig.
  • Event Tracking: Built-in hooks via MarkdownListener for analytics and interaction tracking.

Related

  • Project
  • Project
  • Project
  • Project