Python Markdown parser libraries

Updated Nov 2026

Python Markdown parser libraries turn Markdown text into HTML or into a tree of tokens that code can inspect. A parser either renders HTML directly or exposes the parsed document as tokens before any rendering happens. These libraries let documentation sites and AI chat apps display formatted text written in Markdown.

Popularity

markdown-it-py has the most monthly downloads in this comparison, at 593.6M.

LibraryMonthly downloadsStarsLast releaseLicense
markdown-it-py
593.6M
1.4KNov 2026MIT
Python-Markdown
125.7M
4.3KNov 2026BSD-3-Clause
mistune
73.7M
3.1KOct 2026BSD-3-Clause
markdown2
8.7M
2.8KMar 2026MIT
marko
6.9M
470Oct 2026MIT
commonmark
3.0M
237May 2026BSD-3-Clause
mistletoe
2.8M
1.1KJul 2026MIT
pyromark
506.1K
43Nov 2026MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Parses Markdown into tokens and renders HTML with configurable rules.

Downloads / mo
593.6M
Stars
1.4K
Last release
4.3.0
License
MIT

Strengths

  • Exposes tokens and syntax trees. Parse tokens, build a SyntaxTreeNode, and traverse its children.
  • Lets rules change temporarily. Use reset_rules to restore parsing rules after a temporary change.

Limitations

  • Raw HTML passes through initially. Use js-default for untrusted Markdown or sanitize HTML output.
  • Automatic links need an extra. Install linkify-it-py when enabling linkify or a GFM-like preset.

Quickstart

From README.md
$ pip install markdown-it-py
from markdown_it import MarkdownIt

html = MarkdownIt().render("# Hello")

markdown-it-py examples

From open-source projects on GitHub

Python-Markdown

Converts Markdown into HTML fragments through an extensible parser.

Downloads / mo
125.7M
Stars
4.3K
Last release
3.11.3
License
BSD-3-Clause

Strengths

  • Supports syntax extensions. Enable bundled extensions or add custom syntax through the extension API.
  • Reuses configured parser instances. Convert multiple documents with the same configured Markdown object.

Limitations

  • Follows original Markdown syntax. Choose another parser when CommonMark compatibility is required.
  • Untrusted output needs sanitizing. Sanitize rendered HTML before displaying untrusted input.

Quickstart

From library.md
$ pip install Markdown
import markdown

html = markdown.markdown("# Hello")

Python-Markdown examples

From open-source projects on GitHub

Renders Markdown with configurable plugins, renderers, and AST tokens.

Downloads / mo
73.7M
Stars
3.1K
Last release
3.4.0
License
BSD-3-Clause

Strengths

  • Escapes HTML in reusable parsers. create_markdown escapes raw HTML and rejects unsafe URL schemes by default.
  • Returns structured tokens. Select renderer=None or renderer=ast to receive tokens instead of HTML.

Limitations

  • Legacy helper permits raw HTML. Use mistune.html only for trusted Markdown or sanitize its output.
  • Custom renderers control their output. Keep escaping and URL checks when writing a renderer.

Quickstart

From guide.rst
$ pip install mistune
import mistune

parser = mistune.create_markdown()
html = parser("# Hello")

mistune examples

From open-source projects on GitHub

Implements Markdown in Python.

Downloads / mo
8.7M
Stars
2.8K
Last release
2.5.5
License
MIT

Quickstart

From README.md
$ pip install markdown2
import markdown2

html = markdown2.markdown("# Hello")

markdown2 examples

From open-source projects on GitHub
def clean_markup(text):
    html = markdown2.markdown(text, extras=["cuddled-lists", "fenced-code-blocks", "pyshell"]).strip()
    cleaned = clean_html(html)
    stroke_matches = re.findall(r"~\w+~", cleaned)
    for stroke_match in stroke_matches:
        cleaned_match = stroke_match.strip("~")
        cleaned = cleaned.replace(stroke_match, cleaned_match)
    return cleaned

Parses CommonMark into an editable document tree with multiple renderers.

Downloads / mo
6.9M
Stars
470
Last release
2.2.5
License
MIT

Strengths

  • Exposes a document tree. Traverse parsed headings, paragraphs, and inline elements.
  • Can normalize Markdown output. Choose MarkdownRenderer to turn parsed documents back into Markdown.

Limitations

  • Use separate instances per thread. Create a new Markdown instance in each thread.

Quickstart

From usage.rst
$ pip install marko
import marko

html = marko.convert("# Hello")

marko examples

From open-source projects on GitHub

Parses Markdown to the CommonMark specification.

Downloads / mo
3.0M
Stars
237
Last release
0.9.2
License
BSD-3-Clause

Quickstart

From main.py
$ pip install commonmark
import commonmark

html = commonmark.commonmark("# Hello")

commonmark examples

From open-source projects on GitHub

Parses Markdown with an extensible API in pure Python.

Downloads / mo
2.8M
Stars
1.1K
Last release
1.6.0
License
MIT

Quickstart

From README.md
$ pip install mistletoe
import mistletoe

html = mistletoe.markdown("# Hello")

mistletoe examples

From open-source projects on GitHub

Parses CommonMark Markdown as a pull parser written in Rust.

Downloads / mo
506.1K
Stars
43
Last release
0.10.6
License
MIT

Quickstart

From _pyromark.pyi
$ pip install pyromark
import pyromark

html = pyromark.html("# Hello")

pyromark examples

From open-source projects on GitHub

FAQ

markdown-it-py suits applications that need CommonMark parsing and access to the token stream. Python-Markdown suits projects that follow the original Markdown rules and rely on its extensions. mistune suits applications that want plugins and custom renderers.

Python-Markdown is a Python implementation of John Gruber's original Markdown that converts text to HTML. Its maintainers do not aim for CommonMark compatibility.

markdown-it-py is a Python port of markdown-it. It exposes the parsed tokens before rendering and follows CommonMark as its baseline.

mistune is a Markdown parser with plugins and renderers. Its maintainers state that the current release follows the CommonMark specification.

Python-Markdown and markdown2 convert a Markdown string to an HTML string. markdown-it-py and mistune render HTML as well and also expose the parsed tokens.

For coding agents

Found your Markdown parser library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official