Comark vs Markdoc
TL;DR: Markdoc (built by Stripe) and Comark both treat Markdown as data, declare components in plain text, and parse at runtime with no build step. Comark adds autoClose for streamed AI output, a tuple-based AST, renderers for Vue, React, Svelte, Angular, HTML, and the terminal, and markdown-it plugin support.
At a glance
| Comark | Markdoc | |
|---|---|---|
| Component syntax | ::callout{type="note"} | {% callout type="note" %} |
| Runtime parsing, no build step | Yes | Yes |
| Serializable AST | Yes, ['tag', props, ...children] | Yes, renderable tree of node objects |
| Streaming incomplete input | autoClose on every parse | Not supported |
| Official renderers | Vue, React, Svelte, Angular, Nuxt, HTML, ANSI | React, HTML |
| Schema validation of tags | No, components validate their own props | Yes, tag and attribute schemas |
| Variables and functions in content | Bindings via :prop="expr" and {{ path }} | Built-in $variables and functions |
| Partials | Handled in application code | Built-in {% partial %} |
| Plugin ecosystem | Comark plugins and markdown-it plugins | Custom nodes and tags configuration |
| Syntax lineage | Markdown directives proposal, 5 years of MDC in Nuxt Content | Stripe's internal docs platform |
Shared philosophy
Both libraries avoid compiling Markdown into JavaScript modules. A Markdoc tag and a Comark component are plain-text declarations:
{% callout type="note" %}
Useful information with **Markdown** inside.
{% /callout %}::callout{type="note"}
Useful information with **Markdown** inside.
::Both parse into a serializable tree, resolve components from a runtime map, and run inside a request handler.
Streaming
Markdoc targets complete documentation files validated against schemas, and doesn't auto-close unfinished syntax.
Comark's auto-close step closes unfinished Markdown and open ::component blocks on every parse, so streamed LLM output renders frame by frame:
import { autoCloseMarkdown } from 'comark'
autoCloseMarkdown('::callout\nStreaming in **prog')
// '::callout\nStreaming in **prog**\n::'AST shape
Comark represents element nodes as compact tuples:
['callout', { type: 'note' }, ['p', {}, 'Useful information']]Markdoc represents nodes as objects carrying type, tag, attributes, children, and transform metadata. Comark's tuple format keeps JSON.stringify() payloads compact when sending parsed documents from a server to a client. See the document model.
Framework coverage
Markdoc officially renders to React and HTML. Comark ships official renderers for Vue, React, Svelte, Angular, and Nuxt, plus HTML and ANSI string output, all consuming the same AST.
What Markdoc does well
- Schema validation: Markdoc lets you declare each tag's allowed attributes and children, then validate documents against those schemas before rendering. Comark has no schema layer; components validate their own props, and you write structural checks with the AST API.
- Built-in variables, functions, and partials: Markdoc resolves
$variables, calls functions, and includes partials inside content. Comark keeps logic in the application: the binding plugin interpolates frontmatter and runtime data, and composition happens in your components.
If your documentation team needs pre-render schema checks on every tag and attribute, Markdoc provides that validation layer.
FAQ
{% %} syntax is specific to Markdoc.visit() from the AST API to check tags and attributes, or validate props inside your components.{{ path }} expressions from frontmatter, meta, or runtime data, and :prop="expression" binds dynamic values to component props.Comark vs Streamdown
Streamdown streams Markdown in React. Comark streams Markdown with custom component syntax in Vue, React, Svelte, and Angular, with a decoupled parser and serializable AST.
Comark vs Markstream
Markstream and Comark both stream AI Markdown in several frameworks. Compare incomplete-syntax handling, components in content, string renderers, security defaults, and renderer maturity.