Why Comark? One Markdown Pipeline for Every Renderer

Comark gives JavaScript applications one Markdown pipeline for standards-based parsing, serializable documents, multiple renderers, plugins, and streaming.

Writing Markdown is the solved part. The work starts after: parsing it into structured data, rendering custom UI components, targeting more than one output format, and updating the screen while an AI response streams.

Comark is an open-source Markdown parser and renderer with components, attributes, and plugins. It parses Markdown into a serializable document and renders it to Vue, React, Svelte, Angular, HTML, and ANSI terminal output.

Why Markdown?

Web content often has two readers: people who write and scan prose, and programs or language models that consume structure.

HTML is verbose, and extra markup costs tokens whenever a model reads or writes a page. JSON is structured, but nobody wants to write documentation or articles in JSON.

Markdown sits between the two. John Gruber designed it in 2004 as plain text that is easy to read and converts to HTML. Those same properties make it practical for language models and developer tools.

Token cost and structure

Serving the same page as Markdown instead of HTML can use roughly 80% fewer tokens. Fewer tokens mean lower API cost, faster responses, and more room in the context window.

Markdown also marks structure with minimal noise. A ## prefix marks a section heading directly, whereas HTML wraps the same text in tags and class attributes such as <h2 class="...">.

Streaming and agent tooling

Language models output Markdown by default and stream it token by token. Renderers such as react-markdown expect a complete document, so unclosed fences and emphasis markers break formatting mid-stream. Vercel built Streamdown to handle streamed Markdown in React with useChat from @ai-sdk/react (Comark vs Streamdown).

Developer tools also use Markdown for configuration. Files such as AGENTS.md, CLAUDE.md, and .cursorrules configure GitHub Copilot, Claude Code, and Cursor. Developers edit them as normal docs, and tools pass them straight into prompts.

Why Comark?

Most JavaScript Markdown libraries handle one part of the pipeline. A renderer may target a single UI framework. A build-time compiler may only read local files instead of database rows or API responses. A standard parser assumes the input is complete, which breaks formatting during a stream.

Comark separates parsing from rendering. It parses Markdown into a shared document model, lets you inspect or store that document as JSON, and renders it through the package for your target. The same API runs at build time or runtime, on the server or in the browser, on complete text or a live stream.

Built on markdown-it

Comark supports CommonMark and GitHub Flavored Markdown (GFM) through markdown-exit, a TypeScript rewrite of markdown-it that keeps its plugin API. Standard Markdown works as expected, and markdown-it parsing plugins work alongside Comark plugins.

Markdown as data, not code

parseMarkdown(markdown) returns a compact, serializable MarkdownDocument. Text stays as strings, elements use tuples such as ['tag', props, ...children], and plugins attach metadata to meta.

That document boundary supports a four-step pipeline:

  1. Read raw Markdown from a file, database, CMS, or API.
  2. Parse it with parseMarkdown(markdown) to get a MarkdownDocument.
  3. Inspect, transform, cache, or send the document as JSON.
  4. Render the final output with the HTML, ANSI, Vue, React, Svelte, or Angular renderer.

You parse once and render anywhere without tying stored content to a framework or bundler.

Store the MarkdownDocument directly in your database or cache to skip parsing on every request.

One source, every renderer

Because parsing is separate from rendering, one Markdown source can target:

Adding a terminal view, an HTML email, or another web framework doesn't require rewriting your Markdown files.

Streaming in the parser

Comark's auto-close step closes unfinished emphasis, links, code fences, tables, and component blocks before each parse, so intermediate frames render without raw syntax markers.

Framework renderers expose a streaming prop that reuses completed blocks across updates. Any custom integration can use the same behavior through parseMarkdown() or autoCloseMarkdown().

Components without embedded code

Standard Markdown has no syntax for callouts, tabbed code groups, video embeds, or pricing cards. Raw HTML is verbose and mixes markup into prose. MDX embeds JSX and JavaScript, which ties content to a bundler (Comark vs MDX).

Comark keeps custom blocks in plain text. Its component syntax follows the CommonMark directives proposal and builds on five years of production use in MDC:

::alert{type="warning"}
This action cannot be undone.
::

The source stays readable in a text editor. The parser produces an alert node with { type: 'warning' } and its children. The renderer mounts only components you register in your app, so content stays data and never executes code.

Inline attributes ({.lead #intro}) add classes, IDs, and metadata to standard Markdown elements the same way. Plain CommonMark and GFM continue to work unchanged.

Named slots

Components can accept Markdown in named regions using #slot markers, with no HTML wrappers or template imports:

::hero
#title
Build UIs from **Markdown**

#description
Comark parses component syntax at runtime with no build step.
Renders to HTML, ANSI, Vue, React, Svelte, and Angular.

#cta
[Get started](/getting-started/installation)
::

Each slot accepts full Markdown, including formatting, links, code blocks, and nested components, and maps to native slots, props, or snippets in your renderer.

© 2026 Vercel, Inc.