---
title: "Alir3z4/html2text: Convert HTML to Markdown-formatted text."
description: "!https://github.com/Alir3z4/html2text"
date: 2024-05-01
published: true
tags:
  - thought
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://github.com/Alir3z4/html2text" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-image">
      <img src="https://opengraph.githubassets.com/0359b90a7f1ab1045ca0306912d2384552d5ac7b09a1f059f49b702504060f4a/Alir3z4/html2text" alt="GitHub - Alir3z4/html2text: Convert HTML to Markdown-formatted text. — Convert HTML to Markdown-formatted text. Contribute to Alir3z4/html2text development by creating an account on GitHub." loading="lazy">
    </div>
    <div class="embed-card-content">
      <div class="embed-card-title">GitHub - Alir3z4/html2text: Convert HTML to Markdown-formatted text.</div>
      <div class="embed-card-description">Convert HTML to Markdown-formatted text. Contribute to Alir3z4/html2text development by creating an account on GitHub.</div>
      <div class="embed-card-meta">GitHub &middot; github.com</div>
    </div>
  </a>
</div>


Super neat tool to convert html to markdown

``` python
>>> import html2text
>>>
>>> print(html2text.html2text("<p><strong>Zed's</strong> dead baby, <em>Zed's</em> dead.</p>"))
**Zed's** dead baby, _Zed's_ dead.
```

It even plays nicely with rich.

``` python
from rich.markdown import Markdown
from rich.console import Console
import html2text
console = Console()
md = Markdown(html2text.html2text("<p><strong>Zed's</strong> dead baby, <em>Zed's</em> dead.</p>"))
console.print(md)
``` 
