markdown-it vs marked vs remark vs remark-parse vs unified
Markdown Parsing Libraries
markdown-itmarkedremarkremark-parseunifiedSimilar Packages:

Markdown Parsing Libraries

Markdown parsing libraries are essential tools in web development for converting Markdown text into HTML. They facilitate the rendering of Markdown content in web applications, enabling developers to provide rich text formatting options without the complexities of HTML. Each library offers unique features, performance characteristics, and extensibility options, catering to different use cases and developer preferences.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
markdown-it021,377768 kB603 months agoMIT
marked036,789449 kB7a day agoMIT
remark08,85015.7 kB83 years agoMIT
remark-parse08,85019.5 kB83 years agoMIT
unified04,976146 kB12 years agoMIT

Feature Comparison: markdown-it vs marked vs remark vs remark-parse vs unified

Performance

  • markdown-it:

    markdown-it is designed for speed and efficiency, making it one of the fastest Markdown parsers available. It utilizes a streaming approach, allowing it to handle large documents with minimal overhead, which is crucial for performance-sensitive applications.

  • marked:

    marked is known for its high performance and low memory footprint. It is optimized for speed, making it suitable for applications that need to render Markdown content quickly without compromising on performance.

  • remark:

    remark is slightly slower due to its extensive processing capabilities, but it provides a robust framework for transforming Markdown content. It is best used in scenarios where performance is less critical than the need for advanced processing features.

  • remark-parse:

    remark-parse is efficient for parsing Markdown into an AST, but its performance will depend on how the AST is used in subsequent processing. It is optimized for parsing rather than rendering, making it suitable for analysis and manipulation tasks.

  • unified:

    unified's performance can vary based on the complexity of the transformations applied. It is designed for flexibility and extensibility, which may introduce some overhead, but it excels in scenarios requiring multiple content transformations.

Extensibility

  • markdown-it:

    markdown-it offers a rich plugin architecture that allows developers to extend its functionality easily. You can add custom rules and plugins to enhance the parsing process, making it highly adaptable to specific needs.

  • marked:

    marked is relatively straightforward and does not have a built-in plugin system. However, it can be extended through custom implementations, making it less flexible compared to other libraries.

  • remark:

    remark is highly extensible, with a vast ecosystem of plugins available for various transformations and enhancements. It allows for custom processing pipelines, making it ideal for complex Markdown manipulation.

  • remark-parse:

    remark-parse is a part of the remark ecosystem and is designed to be used with other remark plugins. While it focuses on parsing, it can be easily integrated into a larger processing pipeline with other remark tools.

  • unified:

    unified is inherently extensible, allowing developers to create custom processors and integrate various plugins for different content types. This modular approach makes it suitable for projects requiring diverse content handling.

Learning Curve

  • markdown-it:

    markdown-it has a moderate learning curve, especially for developers familiar with Markdown. Its API is straightforward, but leveraging its plugin system may require additional understanding of its architecture.

  • marked:

    marked is easy to learn and implement, making it a great choice for beginners. Its simple API allows developers to get started quickly with minimal setup.

  • remark:

    remark has a steeper learning curve due to its comprehensive nature and the need to understand its plugin architecture. However, it offers powerful capabilities for those willing to invest the time to learn.

  • remark-parse:

    remark-parse is straightforward to use for parsing Markdown into an AST, but understanding how to manipulate the AST may require additional learning. It is best suited for developers familiar with abstract syntax trees.

  • unified:

    unified has a higher learning curve due to its modular architecture and the need to understand how to work with different processors and plugins. It is best suited for experienced developers looking for flexibility.

Output Format

  • markdown-it:

    markdown-it outputs HTML directly from Markdown, making it ideal for applications that require immediate rendering of Markdown content. It supports various options for customizing the output HTML.

  • marked:

    marked also outputs HTML from Markdown and is designed for simplicity. It provides a clean and straightforward conversion process, making it easy to integrate into applications.

  • remark:

    remark allows for outputting Markdown as an AST, which can then be transformed into various formats, including HTML. This flexibility is beneficial for projects that require multiple output formats.

  • remark-parse:

    remark-parse outputs an abstract syntax tree (AST) from Markdown, which can be further processed or transformed. It is not designed for direct HTML output, making it suitable for analysis and manipulation tasks.

  • unified:

    unified can output various formats, including HTML, Markdown, and more, depending on the processors used in the pipeline. This versatility makes it suitable for projects that require different output formats.

Community and Support

  • markdown-it:

    markdown-it has a strong community and is widely used in various projects, ensuring good support and a wealth of plugins and resources available for developers.

  • marked:

    marked is popular and has a solid user base, providing ample resources and community support, although it may not have as extensive a plugin ecosystem as markdown-it.

  • remark:

    remark boasts a vibrant community with numerous plugins and extensive documentation, making it a great choice for developers looking for support and resources.

  • remark-parse:

    remark-parse benefits from the larger remark community, providing access to a wealth of resources and plugins for Markdown processing.

  • unified:

    unified has a growing community and a strong ecosystem of plugins, making it a good choice for developers looking for support and extensibility in their content processing workflows.

How to Choose: markdown-it vs marked vs remark vs remark-parse vs unified

  • markdown-it:

    Choose markdown-it if you need a fast, extensible, and customizable Markdown parser that supports a wide range of plugins and features. It is ideal for applications where performance is critical and you want to leverage a rich ecosystem of plugins for additional functionality.

  • marked:

    Select marked if you require a simple and efficient Markdown parser that is easy to use and has a straightforward API. It is suitable for projects where speed is essential, and you need a quick solution without the overhead of additional features.

  • remark:

    Opt for remark if you are looking for a comprehensive Markdown processing toolchain that allows for extensive transformations and plugins. It is perfect for projects that need to manipulate Markdown content beyond simple parsing, offering a powerful ecosystem for custom processing.

  • remark-parse:

    Use remark-parse if you need a specialized parser that focuses solely on converting Markdown to an abstract syntax tree (AST). This is beneficial for projects that require further processing or analysis of Markdown content before rendering it to HTML.

  • unified:

    Choose unified if you want a versatile framework that allows you to work with different types of content transformations, including Markdown. It is ideal for projects that require a modular approach to content processing and the ability to integrate various plugins for different formats.

README for markdown-it

markdown-it

CI NPM version Coverage Status Gitter

Markdown parser done right. Fast and easy to extend.

Live demo

  • Follows the CommonMark spec + adds syntax extensions & sugar (URL autolinking, typographer).
  • Configurable syntax! You can add new rules and even replace existing ones.
  • High speed.
  • Safe by default.
  • Community-written plugins and other packages on npm.

Table of content

Install

node.js:

npm install markdown-it

browser (CDN):

Usage examples

See also:

Simple

// node.js
// can use `require('markdown-it')` for CJS
import markdownit from 'markdown-it'
const md = markdownit()
const result = md.render('# markdown-it rulezz!');

// browser with UMD build, added to "window" on script load
// Note, there is no dash in "markdownit".
const md = window.markdownit();
const result = md.render('# markdown-it rulezz!');

Single line rendering, without paragraph wrap:

import markdownit from 'markdown-it'
const md = markdownit()
const result = md.renderInline('__markdown-it__ rulezz!');

Init with presets and options

(*) presets define combinations of active rules and options. Can be "commonmark", "zero" or "default" (if skipped). See API docs for more details.

import markdownit from 'markdown-it'

// commonmark mode
const md = markdownit('commonmark')

// default mode
const md = markdownit()

// enable everything
const md = markdownit({
  html: true,
  linkify: true,
  typographer: true
})

// full options list (defaults)
const md = markdownit({
  // Enable HTML tags in source
  html:         false,

  // Use '/' to close single tags (<br />).
  // This is only for full CommonMark compatibility.
  xhtmlOut:     false,

  // Convert '\n' in paragraphs into <br>
  breaks:       false,

  // CSS language prefix for fenced blocks. Can be
  // useful for external highlighters.
  langPrefix:   'language-',

  // Autoconvert URL-like text to links
  linkify:      false,

  // Enable some language-neutral replacement + quotes beautification
  // For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.mjs
  typographer:  false,

  // Double + single quotes replacement pairs, when typographer enabled,
  // and smartquotes on. Could be either a String or an Array.
  //
  // For example, you can use 'ยซยปโ€žโ€œ' for Russian, 'โ€žโ€œโ€šโ€˜' for German,
  // and ['ยซ\xA0', '\xA0ยป', 'โ€น\xA0', '\xA0โ€บ'] for French (including nbsp).
  quotes: 'โ€œโ€โ€˜โ€™',

  // Highlighter function. Should return escaped HTML,
  // or '' if the source string is not changed and should be escaped externally.
  // If result starts with <pre... internal wrapper is skipped.
  highlight: function (/*str, lang*/) { return ''; }
});

Plugins load

import markdownit from 'markdown-it'

const md = markdownit
  .use(plugin1)
  .use(plugin2, opts, ...)
  .use(plugin3);

Syntax highlighting

Apply syntax highlighting to fenced code blocks with the highlight option:

import markdownit from 'markdown-it'
import hljs from 'highlight.js' // https://highlightjs.org

// Actual default values
const md = markdownit({
  highlight: function (str, lang) {
    if (lang && hljs.getLanguage(lang)) {
      try {
        return hljs.highlight(str, { language: lang }).value;
      } catch (__) {}
    }

    return ''; // use external default escaping
  }
});

Or with full wrapper override (if you need assign class to <pre> or <code>):

import markdownit from 'markdown-it'
import hljs from 'highlight.js' // https://highlightjs.org

// Actual default values
const md = markdownit({
  highlight: function (str, lang) {
    if (lang && hljs.getLanguage(lang)) {
      try {
        return '<pre><code class="hljs">' +
               hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
               '</code></pre>';
      } catch (__) {}
    }

    return '<pre><code class="hljs">' + md.utils.escapeHtml(str) + '</code></pre>';
  }
});

Linkify

linkify: true uses linkify-it. To configure linkify-it, access the linkify instance through md.linkify:

md.linkify.set({ fuzzyEmail: false });  // disables converting email to link

API

API documentation

If you are going to write plugins, please take a look at Development info.

Syntax extensions

Embedded (enabled by default):

Via plugins:

Manage rules

By default all rules are enabled, but can be restricted by options. On plugin load all its rules are enabled automatically.

import markdownit from 'markdown-it'

// Activate/deactivate rules, with currying
const md = markdownit()
  .disable(['link', 'image'])
  .enable(['link'])
  .enable('image');

// Enable everything
const md = markdownit({
  html: true,
  linkify: true,
  typographer: true,
});

You can find all rules in sources:

Benchmark

Here is the result of readme parse at MB Pro Retina 2013 (2.4 GHz):

npm run benchmark-deps
benchmark/benchmark.mjs readme

Selected samples: (1 of 28)
 > README

Sample: README.md (7774 bytes)
 > commonmark-reference x 1,222 ops/sec ยฑ0.96% (97 runs sampled)
 > current x 743 ops/sec ยฑ0.84% (97 runs sampled)
 > current-commonmark x 1,568 ops/sec ยฑ0.84% (98 runs sampled)
 > marked x 1,587 ops/sec ยฑ4.31% (93 runs sampled)

Note. CommonMark version runs with simplified link normalizers for more "honest" compare. Difference is โ‰ˆ1.5ร—.

As you can see, markdown-it doesn't pay with speed for its flexibility. Slowdown of "full" version caused by additional features not available in other implementations.

markdown-it for enterprise

Available as part of the Tidelift Subscription.

The maintainers of markdown-it and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Authors

markdown-it is the result of the decision of the authors who contributed to 99% of the Remarkable code to move to a project with the same authorship but new leadership (Vitaly and Alex). It's not a fork.

References / Thanks

Big thanks to John MacFarlane for his work on the CommonMark spec and reference implementations. His work saved us a lot of time during this project's development.

Related Links:

Ports