Utility Coder
Back to Blog
converter

HTML To Markdown

Andy Pham
html to markdown, html to markdown, html to markdown online

Ready to try HTML To Markdown?

Access the free online tool now - no registration required

Open Tool

HTML To Markdown - Complete Guide

HTML to Markdown conversion transforms HTML content into clean Markdown syntax. This is useful for migrating content from HTML-based systems to Markdown-based platforms, creating editable content from web pages, or simplifying HTML for documentation.

How It Works

The converter parses HTML DOM, identifies semantic elements, and outputs Markdown equivalents.

becomes #, becomes **, becomes text,
  • becomes - items. Complex HTML may require lossy conversion or custom handling.

    Technical Details

    Conversion maps: headings to # syntax, emphasis to /* markers, links to syntax, images to syntax, lists to -/* or 1. prefixes, code to backticks or fenced blocks. Nested formatting, tables, and non-standard HTML require special handling.

    Common Use Cases

    1. Content Migration: Convert CMS HTML content to Markdown files.
      • Example: <h1>Title</h1><p>Text</p> → # Title\n\nText
    2. Web Scraping: Extract readable Markdown from web pages.
    3. Email Processing: Convert HTML emails to Markdown for archiving.
    4. WYSIWYG Editors: Save rich editor content as Markdown.

    Code Examples

    Node.js with turndown

    const TurndownService = require('turndown');
    
    const turndown = new TurndownService({
      headingStyle: 'atx',      // # style headers
      codeBlockStyle: 'fenced'  // ``` style code
    });
    
    const html = '<h1>Hello</h1><p>World <strong>bold</strong></p>';
    const markdown = turndown.turndown(html);
    // # Hello\n\nWorld **bold**
    
    // Add custom rule
    turndown.addRule('strikethrough', {
      filter: ['del', 's'],
      replacement: (content) => '~~' + content + '~~'
    });
    

    Turndown is the most popular HTML-to-Markdown converter. Supports custom rules for special elements.

    Python with markdownify

    from markdownify import markdownify as md
    
    html = """
    <h1>Hello World</h1>
    <p>This is <strong>bold</strong> and <em>italic</em>.</p>
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
    </ul>
    """
    
    markdown = md(html, heading_style='ATX', bullets='-')
    # # Hello World
    #
    # This is **bold** and *italic*.
    #
    # - Item 1
    # - Item 2
    

    markdownify provides simple conversion with configurable options for different Markdown styles.

    Tips & Best Practices

    • Clean up HTML before conversion (remove scripts, styles, ads)
    • Use GFM-compatible output for tables and task lists
    • Test with representative content before batch conversion
    • Handle images - convert URLs or download and update paths
    • Post-process output to fix formatting inconsistencies

    Common Mistakes to Avoid

    • Converting complex HTML without cleanup first
    • Expecting perfect round-trip (HTML→MD→HTML)
    • Not handling relative URLs in links and images
    • Ignoring table complexity limits in Markdown

    When to Use This Tool

    Use HTML to Markdown when migrating content to Markdown-based systems, extracting readable content from web pages, or converting WYSIWYG editor output to Markdown format.

    Frequently Asked Questions

    What HTML features don't convert well?

    Complex tables (use GFM tables where possible), forms, iframes, scripts, custom elements, and heavily styled content. Some converters output raw HTML for unsupported elements.

    How are HTML tables converted?

    Simple tables convert to GFM table syntax (| column |). Complex tables with colspan/rowspan may become raw HTML or simplified. Check your converter's table support.

    What about inline styles and classes?

    CSS styles and classes are typically stripped since Markdown doesn't support styling. The semantic content is preserved, but visual formatting is lost.

    Can I preserve some HTML in the output?

    Yes, most converters have options to keep certain HTML tags as-is. Useful for elements with no Markdown equivalent like

    , , or custom elements.

    Get Started

    Ready to try HTML To Markdown? Use the tool now - it's free, fast, and works right in your browser.


    Last updated: June 27, 2026

    Start using HTML To Markdown

    Free, fast, and privacy-focused - try it now

    Launch Tool