datamark vs Remark Plugins

Using the unified/remark ecosystem for AST transformation compared to datamark's lightweight format system.

The unified/remark ecosystem is the dominant toolchain for Markdown processing in JavaScript. How does datamark compare?

The remark approach

Remark gives you an AST (mdast) and lets you write plugins that transform it:

import { unified } from "unified";
import remarkParse from "remark-parse";

const tree = unified().use(remarkParse).parse(content);
// Now write a visitor that walks the tree

This is powerful and well-supported, but it is fundamentally imperative. You write a visitor that mutates or inspects nodes. The structure of your code does not mirror the structure of your document.

The datamark approach

datamark gives you a unified AST with a native section tree, plus utility functions for querying and extracting data:

function parse(doc) {
  const h1 = doc.root.children.find(n => n.type === "section");
  const title = h1 ? inlineText(h1.heading.children) : "";
  const sections = h1?.children.filter(n => n.type === "section") ?? [];
  return { title, sections };
}

This reads like the document itself. The section tree mirrors the heading hierarchy, and utility functions make common patterns trivial.

FeatureRemarkdatamark
Ecosystem size✅ MassiveSmall
AST standardmdastdatamark AST
Plugin modelVisitor-basedImperative + utilities
Bidirectional❌ (separate stringify)✅ Built-in
TypeScriptPartialFully typed
FrontmatterVia pluginBuilt-in
ValidationVia pluginStandard Schema
Learning curveMediumLow

When to use remark

If you need to transform Markdown to HTML, apply syntax highlighting, generate a table of contents, or integrate with a massive plugin ecosystem, remark is the right choice.

If you need to parse Markdown into typed objects and optionally serialize them back, datamark is purpose-built for that job.

On this page