Skip to main content
MarkdownView Demo MarkdownView is a native Swift library that brings powerful markdown rendering to iOS, macOS, and visionOS applications. Built on tree-sitter’s native parsers and swift-cmark, it delivers exceptional performance without JavaScript runtime overhead.

Get started

Installation

Add MarkdownView to your project using Swift Package Manager

Quickstart

Get up and running with your first markdown view in minutes

Key features

Full GFM support

Complete GitHub Flavored Markdown support including headings, lists, tables, blockquotes, task lists, and more

Native syntax highlighting

Tree-sitter-powered highlighting for 19 languages: Swift, C, C++, C#, Python, JavaScript, TypeScript, TSX, Go, Rust, Java, Kotlin, Ruby, Bash, SQL, YAML, JSON, HTML, and CSS

LaTeX math rendering

Beautiful mathematical expressions rendered natively without external dependencies

Inline image support

Async image loading with caching for smooth scrolling performance

Comprehensive theming

Customize fonts, colors, spacing, and more to match your app’s design

Text selection

Long-press, double-tap, and triple-tap gestures for natural text selection

VoiceOver accessible

Full accessibility support for text, code blocks, tables, and math content

UIKit and AppKit

Single unified API works seamlessly across iOS, macOS, and visionOS

Performance

MarkdownView uses tree-sitter’s native C parsers instead of JavaScript-based solutions like highlight.js. This eliminates the JavaScriptCore runtime entirely and produces color ranges directly from semantic parse trees.
Language parsers are initialized lazily — only the languages actually used in your markdown are loaded.
BenchmarkTime
Plain-text stream append (steady-state)<0.1 ms
Highlight 50 lines~2 ms
Highlight 500 lines~21 ms
Parse 500 blocks~5 ms
Parse + preprocess 300 blocks~3 ms
The plain-text streaming fast path applies to safe token appends that do not introduce new markdown syntax, allowing the view to skip reparsing and update only the trailing paragraph.

Requirements

  • iOS 16+ / macOS 13+ / visionOS 1+
  • Swift 5.9+

Architecture

The library is split into two modules:
  • MarkdownParser — Converts markdown strings into an AST using swift-cmark with GFM extensions. No UI dependencies.
  • MarkdownView — Renders the AST into native views with syntax highlighting, math rendering, and interactive links.
This separation allows you to parse markdown on background threads and render it on the main thread for optimal performance.

Build docs developers (and LLMs) love