Github url


by markdown-it

markdown-it /markdown-it

Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed

9.9K Stars 899 Forks Last release: Not found MIT License 939 Commits 61 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Build StatusNPM versionCoverage StatusGitter

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


node.js & bower:

npm install markdown-it --save bower install markdown-it --save

browser (CDN):

Usage examples

See also:


// node.js, "classic" way: var MarkdownIt = require('markdown-it'), md = new MarkdownIt(); var result = md.render('# markdown-it rulezz!'); // node.js, the same, but with sugar: var md = require('markdown-it')(); var result = md.render('# markdown-it rulezz!'); // browser without AMD, added to "window" on script load // Note, there is no dash in "markdownit". var md = window.markdownit(); var result = md.render('# markdown-it rulezz!');

Single line rendering, without paragraph wrap:

var md = require('markdown-it')(); var result = md.renderInline('\_\_markdown-it\_\_ rulezz!');

Init with presets and options

(*) presets define combinations of active rules and options. Can be






(if skipped). SeeAPI docs for more details.

// commonmark mode var md = require('markdown-it')('commonmark'); // default mode var md = require('markdown-it')(); // enable everything var md = require('markdown-it')({ html: true, linkify: true, typographer: true }); // full options list (defaults) var md = require('markdown-it')({ html: false, // Enable HTML tags in source xhtmlOut: false, // Use '/' to close single tags (
). // This is only for full CommonMark compatibility. breaks: false, // Convert '\n' in paragraphs into 
 langPrefix: 'language-', // CSS language prefix for fenced blocks. Can be // useful for external highlighters. linkify: false, // Autoconvert URL-like text to links // Enable some language-neutral replacement + quotes beautification 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 lang return>
<h3>Plugins load</h3>
<pre class="js">var md = require('markdown-it')()
            .use(plugin2, opts, ...)
<h3>Syntax highlighting</h3>

<p>Apply syntax highlighting to fenced code blocks with the </p><pre class="">highlight</pre> option:
<pre class="js">var hljs = require('highlight.js'); //

// Actual default values
var md = require('markdown-it')({
  highlight: function (str, lang) {
    if (lang &amp;&amp; hljs.getLanguage(lang)) {
      try {
        return hljs.highlight(lang, str).value;
      } catch (__) {}

    return ''; // use external default escaping
<p>Or with full wrapper override (if you need assign class to </p><pre class=""><pre></pre>):
<pre class="js">var hljs = require('highlight.js'); //

// Actual default values
var md = require('markdown-it')({
  highlight: function (str, lang) {
    if (lang &amp;&amp; hljs.getLanguage(lang)) {
      try {
        return '<pre class="hljs"><code>' +
               hljs.highlight(lang, str, true).value +
      } catch (__) {}

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

<p></p><pre class="">linkify: true</pre> uses <a href="">linkify-it</a>. To
configure linkify-it, access the linkify instance through <pre class="">md.linkify</pre>:
<pre class="js">md.linkify.tlds('.py', false); // disables .py as top level domain

<p><strong><a href="">API documentation</a></strong></p>

<p>If you are going to write plugins - take a look at
<a href="">Development info</a>.</p>

<h2>Syntax extensions</h2>

<p>Embedded (enabled by default):</p>

<a href="">Tables</a> (GFM)</li>
<a href="">Strikethrough</a> (GFM)</li>

<p>Via plugins:</p>

<li><a href="">subscript</a></li>
<li><a href="">superscript</a></li>
<li><a href="">footnote</a></li>
<li><a href="">definition list</a></li>
<li><a href="">abbreviation</a></li>
<li><a href="">emoji</a></li>
<li><a href="">custom container</a></li>
<li><a href="">insert</a></li>
<li><a href="">mark</a></li>
<li>... and <a href="">others</a>

<h3>Manage rules</h3>

<p>By default all rules are enabled, but can be restricted by options. On plugin
load all its rules are enabled automatically.</p>
<pre class="js">// Activate/deactivate rules, with curring
var md = require('markdown-it')()
            .disable(['link', 'image'])

// Enable everything
md = require('markdown-it')({
  html: true,
  linkify: true,
  typographer: true,
<p>You can find all rules in sources:
<a href="">parser_core.js</a>, <a href="">parser_block</a>,
<a href="">parser_inline</a>.</p>


<p>Here is the result of readme parse at MB Pro Retina 2013 (2.4 GHz):</p>
<pre class="bash">make benchmark-deps
benchmark/benchmark.js readme

Selected samples: (1 of 28)
 &gt; README

Sample: (7774 bytes)
 &gt; commonmark-reference x 1,222 ops/sec ±0.96% (97 runs sampled)
 &gt; current x 743 ops/sec ±0.84% (97 runs sampled)
 &gt; current-commonmark x 1,568 ops/sec ±0.84% (98 runs sampled)
 &gt; marked x 1,587 ops/sec ±4.31% (93 runs sampled)
<p><strong>Note.</strong> CommonMark version runs with <a href="">simplified link normalizers</a>
for more "honest" compare. Difference is ~ 1.5x.</p>

<p>As you can see, </p><pre class="">markdown-it</pre> doesn't pay with speed for it's flexibility.
Slowdown of "full" version caused by additional features not available in
other implementations.

<h2>markdown-it for enterprise</h2>

<p>Available as part of the Tidelift Subscription.</p>

<p>The maintainers of </p><pre class="">markdown-it</pre> 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. <a href=";utm_medium=referral&amp;utm_campaign=enterprise&amp;utm_term=repo">Learn more.</a>


<li>Alex Kocharin <a href="">github/rlidwka</a>
<li>Vitaly Puzrin <a href="">github/puzrin</a>

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

<h2>References / Thanks</h2>

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

<p><strong>Related Links:</strong></p>

<li> - reference CommonMark implementations in C &amp; JS,
also contains latest spec &amp; online demo.</li>
<li> - CommonMark forum, good place to collaborate
developers' efforts.</li>


<a href="">motion-markdown-it</a> - Ruby/RubyMotion</li>
<a href="">markdown-it-py</a>- Python</li>

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.