{"name":"html2text: Convert HTML to Clean, Readable Markdown Text in Python","description":"html2text is a powerful Python script designed to transform HTML content into clean, easy-to-read plain ASCII text, formatted as valid Markdown. This tool is ideal for developers needing to process web content or convert rich text into a more manageable, structured plain text format. It offers both command-line utility and a flexible Python API for integration into projects.","github":"https://github.com/Alir3z4/html2text","url":"https://osrepos.com/repo/alir3z4-html2text","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/alir3z4-html2text","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/alir3z4-html2text.md","json":"https://osrepos.com/repo/alir3z4-html2text.json","topics":["markdown","markdown-parser","python","html conversion","text processing","command-line tool","developer tools"],"keywords":["markdown","markdown-parser","python","html conversion","text processing","command-line tool","developer tools"],"stars":null,"summary":"html2text is a powerful Python script designed to transform HTML content into clean, easy-to-read plain ASCII text, formatted as valid Markdown. This tool is ideal for developers needing to process web content or convert rich text into a more manageable, structured plain text format. It offers both command-line utility and a flexible Python API for integration into projects.","content":"## Introduction\n`html2text` is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to be valid Markdown, a popular text-to-HTML format. Originally written by Aaron Swartz, this tool provides a robust solution for transforming complex HTML structures into simple, readable Markdown.\n\n## Installation\nYou can easily install `html2text` using pip, as it is available on PyPI.\n\nshell\n$ pip install html2text\n\n\n## Examples\n`html2text` can be used both as a command-line tool and within your Python applications.\n\n### Command-line Usage\nHere are some common options for command-line usage:\n\n*   `--ignore-links`: Don't include any formatting for links.\n*   `--escape-all`: Escape all special characters. Output is less readable, but avoids corner case formatting issues.\n*   `--reference-links`: Use reference links instead of inline links to create markdown.\n*   `--mark-code`: Mark preformatted and code blocks with `[code]...[/code]`.\n\nFor a complete list of options, refer to the [official documentation](https://github.com/Alir3z4/html2text/blob/master/docs/usage.md).\n\n### Python Usage\nYou can integrate `html2text` directly into your Python code:\n\npython\nimport html2text\n\nprint(html2text.html2text(\"<p><strong>Zed's</strong> dead baby, <em>Zed's</em> dead.</p>\"))\n# Expected output: **Zed's** dead baby, _Zed's_ dead.\n\n\nYou can also configure its behavior with specific options:\n\npython\nimport html2text\n\nh = html2text.HTML2Text()\n# Ignore converting links from HTML\nh.ignore_links = True\nprint(h.handle(\"<p>Hello, <a href='https://www.google.com/earth/'>world</a>!</p>\"))\n# Expected output: Hello, world!\n\n# Don't ignore links anymore\nh.ignore_links = False\nprint(h.handle(\"<p>Hello, <a href='https://www.google.com/earth/'>world</a>!</p>\"))\n# Expected output: Hello, [world](https://www.google.com/earth/)!\n\n\n## Why Use It?\nConverting HTML to Markdown offers several advantages. Markdown is lightweight, human-readable, and easy to write, making it ideal for documentation, content management, and plain text storage. `html2text` automates this conversion, preserving formatting like bold, italics, and links while stripping away the complexities of HTML tags, resulting in clean and portable text. This is particularly useful for data scraping, content migration, or generating reports from web pages.\n\n## Links\n*   **GitHub Repository**: [https://github.com/Alir3z4/html2text](https://github.com/Alir3z4/html2text)\n*   **PyPI Project**: [https://pypi.org/project/html2text/](https://pypi.org/project/html2text/)\n*   **Documentation**: [https://github.com/Alir3z4/html2text/blob/master/docs/usage.md](https://github.com/Alir3z4/html2text/blob/master/docs/usage.md)","metrics":{"detailViews":0,"githubClicks":1},"dates":{"published":null,"modified":"2026-07-25T20:41:18.000Z"}}