# Python Markdown parser libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [markdown-it-py](#markdown-it-py) | 593.6M | 1.4K | Nov 2026 | MIT |
| [Python-Markdown](#python-markdown) | 125.7M | 4.3K | Nov 2026 | BSD-3-Clause |
| [mistune](#mistune) | 73.7M | 3.1K | Oct 2026 | BSD-3-Clause |
| [markdown2](#markdowntwo) | 8.7M | 2.8K | Mar 2026 | MIT |
| [marko](#marko) | 6.9M | 470 | Oct 2026 | MIT |
| [commonmark](#commonmark) | 3.0M | 237 | May 2026 | BSD-3-Clause |
| [mistletoe](#mistletoe) | 2.8M | 1.1K | Jul 2026 | MIT |
| [pyromark](#pyromark) | 506.1K | 43 | Nov 2026 | MIT |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[markdown-it-py](#markdown-it-py) has the most monthly downloads in this comparison, at 593.6M.

## Capabilities

| Library | Structured Markdown parse | CommonMark baseline |
| --- | --- | --- |
| [markdown-it-py](#markdown-it-py) | Yes | Yes |
| [Python-Markdown](#python-markdown) | No | No |
| [mistune](#mistune) | Yes | Yes |
| [markdown2](#markdowntwo) | No | Undocumented |
| [marko](#marko) | Yes | Yes |
| [commonmark](#commonmark) | Yes | Yes |
| [mistletoe](#mistletoe) | Yes | Yes |
| [pyromark](#pyromark) | Yes | Yes |

## Libraries

### markdown-it-py

[GitHub](https://github.com/executablebooks/markdown-it-py) · [PyPI](https://pypi.org/project/markdown-it-py) · [Docs](https://markdown-it-py.readthedocs.io/en/latest/using.html)

Parses Markdown into tokens and renders HTML with configurable rules.

- Downloads / mo: 593.6M
- Stars: 1.4K
- Last release: 4.3.0
- License: MIT
- Capabilities: [From the markdown-it-py docs](https://markdown-it-py.readthedocs.io/en/latest/using.html)

**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.

**Watch out for**

- **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.

```sh
pip install markdown-it-py
```

**Textualize/rich** (57.8K stars)

[Textualize/rich](https://github.com/Textualize/rich) 

```python
def __init__(
    self,
    markup: str,
    code_theme: str = "monokai",
    justify: JustifyMethod | None = None,
    style: str | Style = "none",
    hyperlinks: bool = True,
    inline_code_lexer: str | None = None,
    inline_code_theme: str | None = None,
) -> None:
    parser = MarkdownIt().enable("strikethrough").enable("table")
    self.markup = markup
    self.parsed = parser.parse(markup)
    self.code_theme = code_theme
    self.justify: JustifyMethod | None = justify
    self.style = style
    self.hyperlinks = hyperlinks
    self.inline_code_lexer = inline_code_lexer
    self.inline_code_theme = inline_code_theme or code_theme

```

[rich/markdown.py](https://github.com/Textualize/rich/blob/3a109ccdffe5b2d0e30684a304fbd388e99ce57b/rich/markdown.py#L549-L567) · [More projects using markdown-it-py →](https://dashboard.exa.ai/playground/search?q=Real%20projects%20using%20markdown-it-py%20to%20parse%20Markdown%20documents&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from markdown_it import MarkdownIt

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

```

From [README.md](https://markdown-it-py.readthedocs.io/en/latest/using.html)

### Python-Markdown

[GitHub](https://github.com/Python-Markdown/markdown) · [PyPI](https://pypi.org/project/Markdown) · [Docs](https://python-markdown.github.io/reference/)

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
- Capabilities: [From the Python-Markdown docs](https://python-markdown.github.io/reference/)

**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.

**Watch out for**

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

```sh
pip install Markdown
```

**getpelican/pelican** (13.4K stars)

[getpelican/pelican](https://github.com/getpelican/pelican) 

```python
def read(self, source_path):
    """Parse content and metadata of markdown files"""

    self._source_path = source_path
    self._md = Markdown(**self.settings["MARKDOWN"])
    with pelican_open(source_path) as text:
        content = self._md.convert(text)

    if hasattr(self._md, "Meta"):
        metadata = self._parse_metadata(self._md.Meta)
    else:
        metadata = {}
    return content, metadata

```

[pelican/readers.py](https://github.com/getpelican/pelican/blob/e8748aba9ad0907a8801646e957b37a02709240d/pelican/readers.py#L344-L356) · [More projects using Python-Markdown →](https://dashboard.exa.ai/playground/search?q=Real%20projects%20using%20Markdown%20to%20parse%20Markdown%20documents&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import markdown

html = markdown.markdown("# Hello")

```

From [library.md](https://pypi.org/pypi/Markdown/3.11.3/json#info.description)

### mistune

[GitHub](https://github.com/lepture/mistune) · [PyPI](https://pypi.org/project/mistune) · [Docs](https://mistune.lepture.com/en/latest/guide.html)

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
- Capabilities: [From the mistune docs](https://mistune.lepture.com/en/latest/guide.html)

**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.

**Watch out for**

- **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.

```sh
pip install mistune
```

**jupyter/nbconvert** (1.9K stars)

[jupyter/nbconvert](https://github.com/jupyter/nbconvert) 

```python
def __init__(
    self,
    renderer: HTMLRenderer,
    block: Optional[BlockParser] = None,
    inline: Optional[InlineParser] = None,
    plugins: Optional[Iterable["Plugin"]] = None,
):
    """Initialize the parser."""
    if block is None:
        block = MathBlockParser()
    if inline is None:
        if MISTUNE_V3:
            inline = MathInlineParser(hard_wrap=False)
        else:
            inline = MathInlineParser(renderer, hard_wrap=False)  # type: ignore[arg-type,misc]
    if plugins is None:
        plugins = (import_plugin(p) for p in self.DEFAULT_PLUGINS)

    super().__init__(renderer, block, inline, plugins)

```

[nbconvert/filters/markdown_mistune.py](https://github.com/jupyter/nbconvert/blob/e681152f214b65387f875aad96a4726994533a0b/nbconvert/filters/markdown_mistune.py#L486-L504) · [More projects using mistune →](https://dashboard.exa.ai/playground/search?q=Real%20projects%20using%20mistune%20to%20parse%20Markdown%20documents&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import mistune

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

```

From [guide.rst](https://pypi.org/pypi/mistune/3.4.0/json#info.description)

### markdown2

[GitHub](https://github.com/trentm/python-markdown2) · [PyPI](https://pypi.org/project/markdown2)

Implements Markdown in Python.

- Downloads / mo: 8.7M
- Stars: 2.8K
- Last release: 2.5.5
- License: MIT
- Capabilities: [From the markdown2 docs](https://github.com/trentm/python-markdown2)

```sh
pip install markdown2
```

**grafana-cold-storage/oncall** (3.9K stars)

[grafana-cold-storage/oncall](https://github.com/grafana-cold-storage/oncall) 

```python
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

```

[engine/common/utils.py](https://github.com/grafana-cold-storage/oncall/blob/af0fbd40558c9a63bcf438589894c440fc434a54/engine/common/utils.py#L260-L267) · [More projects using markdown2 →](https://dashboard.exa.ai/playground/search?q=markdown2%20GitHub%20projects)

**Quickstart**

```python
import markdown2

html = markdown2.markdown("# Hello")

```

From [README.md](https://github.com/trentm/python-markdown2/blob/2.5.5/lib/markdown2.py)

### marko

[GitHub](https://github.com/frostming/marko) · [PyPI](https://pypi.org/project/marko) · [Docs](https://marko-py.readthedocs.io/en/latest/)

Parses CommonMark into an editable document tree with multiple renderers.

- Downloads / mo: 6.9M
- Stars: 470
- Last release: 2.2.5
- License: MIT
- Capabilities: [From the marko docs](https://marko-py.readthedocs.io/en/latest/)

**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.

**Watch out for**

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

```sh
pip install marko
```

**frictionlessdata/frictionless-py** (858 stars)

[frictionlessdata/frictionless-py](https://github.com/frictionlessdata/frictionless-py) 

```python
@property
def description_html(self) -> str:
    """Description in HTML"""
    description = getattr(self, "description", "")
    try:
        html = platform.marko.convert(description)
        html = html.replace("\n", "")
        return html
    except Exception:
        return ""

```

[frictionless/metadata/metadata.py](https://github.com/frictionlessdata/frictionless-py/blob/c08fa29cb0708427ae65bb689ded8e2691078a82/frictionless/metadata/metadata.py#L125-L134) · [More projects using marko →](https://dashboard.exa.ai/playground/search?q=Real%20projects%20using%20marko%20to%20parse%20Markdown%20documents&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import marko

html = marko.convert("# Hello")

```

From [usage.rst](https://pypi.org/pypi/marko/2.2.5/json#info.description)

### commonmark

[GitHub](https://github.com/readthedocs/commonmark.py) · [PyPI](https://pypi.org/project/commonmark) · [Docs](https://commonmarkpy.readthedocs.io/en/latest/)

Parses Markdown to the CommonMark specification.

- Downloads / mo: 3.0M
- Stars: 237
- Last release: 0.9.2
- License: BSD-3-Clause
- Capabilities: [From the commonmark docs](https://commonmarkpy.readthedocs.io/en/latest/)

```sh
pip install commonmark
```

**sunainapai/makesite** (1.9K stars)

[sunainapai/makesite](https://github.com/sunainapai/makesite) 

```python
def read_content(filename):
    """Read content and metadata from file into a dictionary."""
    # Read file content.
    text = fread(filename)

    # Read metadata and save it in a dictionary.
    date_slug = os.path.basename(filename).split('.')[0]
    match = re.search(r'^(?:(\d\d\d\d-\d\d-\d\d)-)?(.+)$', date_slug)
    content = {
        'date': match.group(1) or '1970-01-01',
        'slug': match.group(2),
    }

    # Read headers.
    end = 0
    for key, val, end in read_headers(text):
        content[key] = val

    # Separate content from headers.
    text = text[end:]

    # Convert Markdown content to HTML.
    if filename.endswith(('.md', '.mkd', '.mkdn', '.mdown', '.markdown')):
        try:
            if _test == 'ImportError':
                raise ImportError('Error forced by test')
            import commonmark
            text = commonmark.commonmark(text)
        except ImportError as e:
            log('WARNING: Cannot render Markdown in {}: {}', filename, str(e))

    # Update the dictionary with content and RFC 2822 date.
    content.update({
        'content': text,
        'rfc_2822_date': rfc_2822_format(content['date'])
    })

    return content

```

[makesite.py](https://github.com/sunainapai/makesite/blob/40bb66a10bb7b6cbf9dd9d93b054de95cb20eba6/makesite.py#L79-L116) · [More projects using commonmark →](https://dashboard.exa.ai/playground/search?q=commonmark%20GitHub%20projects)

**Quickstart**

```python
import commonmark

html = commonmark.commonmark("# Hello")

```

From [main.py](https://github.com/readthedocs/commonmark.py/blob/master/commonmark/main.py)

### mistletoe

[GitHub](https://github.com/miyuchina/mistletoe) · [PyPI](https://pypi.org/project/mistletoe)

Parses Markdown with an extensible API in pure Python.

- Downloads / mo: 2.8M
- Stars: 1.1K
- Last release: 1.6.0
- License: MIT
- Capabilities: [From the mistletoe docs](https://github.com/miyuchina/mistletoe)

```sh
pip install mistletoe
```

**AnswerDotAI/llms-txt** (2.7K stars)

[AnswerDotAI/llms-txt](https://github.com/AnswerDotAI/llms-txt) 

```python
@call_parse
def main(
    file_path='llms.txt'  # path to llms.txt file
):
    text = Path(file_path).read_text(encoding="utf-8")
    fragment = mistletoe.markdown(text)
    processed = fragment.replace('.html.md">', '.html">')
    full = f"""<!DOCTYPE html>
    <html>
    <head>
    <title>llms.html</title>
    </head>
    <body>
    {processed}
    </body>
    </html>"""
    Path("llms.html").write_text(full)

```

[llms_txt/txt2html.py](https://github.com/AnswerDotAI/llms-txt/blob/3700a0a624a4a004c6a246789b37f389940b1b58/llms_txt/txt2html.py#L5-L21) · [More projects using mistletoe →](https://dashboard.exa.ai/playground/search?q=mistletoe%20GitHub%20projects)

**Quickstart**

```python
import mistletoe

html = mistletoe.markdown("# Hello")

```

From [README.md](https://pypi.org/pypi/mistletoe/1.6.0/json#info.description)

### pyromark

[GitHub](https://github.com/monosans/pyromark) · [PyPI](https://pypi.org/project/pyromark) · [Docs](https://monosans.github.io/pyromark/)

Parses CommonMark Markdown as a pull parser written in Rust.

- Downloads / mo: 506.1K
- Stars: 43
- Last release: 0.10.6
- License: MIT
- Capabilities: [From the pyromark docs](https://monosans.github.io/pyromark/)

```sh
pip install pyromark
```

**sudoskys/telegramify-markdown** (387 stars)

[sudoskys/telegramify-markdown](https://github.com/sudoskys/telegramify-markdown) 

```python
def _parse(
    markdown: str, options: pyromark.Options, *, latex_escape: bool
) -> tuple[str, tuple]:
    """Preprocess and parse Markdown; return the parsed text and its ranged events.

    Two delimiter readings that the Markdown extensions allow are rarely what
    chat text means, so their delimiters are escaped and the text parsed again
    until neither remains. Escaped delimiters never match again, so this ends.

    - Inline math whose closing ``$`` is directly followed by a digit, as in
      ``$10.49 (~$11.20)``, is two prices (pandoc's rule for ``$`` math).
    - Strikethrough takes ``~~``; a single ``~`` reads as "approximately".
    """
    text = _escape_latex(markdown) if latex_escape else markdown
    text = _preprocess_spoilers(text, options)
    # pyromark >= 0.10 returns a one-shot iterator; materialize it so the
    # delimiter scan and EventWalker can both iterate.
    events = tuple(pyromark.events_with_range(text, options=options))
    while offsets := _literal_delimiters(text, events):
        text = _escape_at(text, offsets)
        events = tuple(pyromark.events_with_range(text, options=options))
    return text, events

```

[src/telegramify_markdown/converter.py](https://github.com/sudoskys/telegramify-markdown/blob/3535c87ecc41e7861bc5f4ffa400871bc93e9075/src/telegramify_markdown/converter.py#L159-L180) · [More projects using pyromark →](https://dashboard.exa.ai/playground/search?q=pyromark%20GitHub%20projects)

**Quickstart**

```python
import pyromark

html = pyromark.html("# Hello")

```

From [_pyromark.pyi](https://github.com/monosans/pyromark/blob/37eee7fa7d86754f7ea998709b25ef280fc4a0f1/python/pyromark/_pyromark.pyi)

## FAQ

### Which Python Markdown parser should I use?

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

### What is Python-Markdown?

[Python-Markdown](#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.

### What is markdown-it-py?

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

### What is mistune?

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

### How do I convert Markdown to HTML in Python?

[Python-Markdown](#python-markdown) and [markdown2](#markdowntwo) convert a Markdown string to an HTML string. [markdown-it-py](#markdown-it-py) and [mistune](#mistune) render HTML as well and also expose the parsed tokens.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python Markdown parser libraries Python-Markdown markdown-it-py Mistune Marko code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
