Parse and render Markdown anywhere.

A JavaScript library to parse and stream Markdown, with renderers for HTML, ANSI, Vue, React, Svelte and Angular, plus components, attributes, and plugins.
Open in playground
# Hello World

A JavaScript library to **parse and render Markdown** anywhere.

```ts
import { parseMarkdown } from 'comark'

const doc = await parseMarkdown('# Hello **World**')
```

## Features

- CommonMark and GFM support
- HTML, ANSI, and framework renderers
- Streaming, components, and plugins

::callout{icon="i-lucide-info"}
Built on markdown-exit, a TypeScript rewrite of markdown-it.
::

// Renderers //

Parse once, render anywhere

Comark parses Markdown into a compact MarkdownDocument. Parse on the server, during a build, or as content streams in, then render it natively in your framework. Your content outlasts your stack.

HTML
A plain string renderer for static site generators, RSS feeds or emails. No framework required.
ANSI
Render Markdown as styled terminal output using ANSI escape codes, perfect for CLIs, scripts, and developer tooling.
Angular
Standalone components for Angular 17+, with the same props and streaming support.
React
The same component API for React, including React Server Components and Next.js.
Vue
Drop the Markdown component in a template. Custom components and plugins are props.
Svelte
Native Svelte 5 rendering with runes. No wrapper framework, no {@html}.

// Streaming //

Built for AI output

A model streams Markdown a few characters at a time. Render it as it lands and your users watch raw asterisks appear, code fences hang open, and the layout jump on every token. Comark closes what is still open, so every frame renders as finished markup.

// Plugins //

Use official plugins, or write your own

Official plugins add syntax highlighting, math, diagrams, table of contents, and more. Write your own against the plugin API or browse all plugins.

highlight.ts
import { parseMarkdown } from 'comark'
import shiki from 'comark/plugins/shiki'
import githubDark from '@shikijs/themes/github-dark'
import githubLight from '@shikijs/themes/github-light'

const document = await parseMarkdown(content, {
  plugins: [
    shiki({
      themes: { light: githubLight, dark: githubDark }
    })
  ]
})

// Syntax //

Components in Markdown

Discover our opt-in syntax for components, attributes, and frontmatter, handled by default plugins you can turn off. CommonMark and GFM are supported by default, so every Markdown file you already have keeps working.

components.md
::alert{type="info"}
This is an **important** message.
::

::card{title="My Card"}
Card content with full **markdown** support.
::

Click the :button[Submit]{type="primary"} to continue.

// FAQ //

Common questions

From Markdown to UI.

Install Comark, pick a renderer, and render your first Markdown document in minutes. Read why Comark exists, or start with the document model.