HTML to Markdown Converter

Convert HTML to clean Markdown instantly. Handles headings, links, images, tables, lists, and code blocks.

Your data never leaves your browser

How to Use

  1. Paste your HTML code into the left input panel.
  2. The Markdown output updates automatically in the right panel as you type or paste.
  3. Toggle Reference-style links to switch between inline and reference link formatting.
  4. Click Copy to copy the generated Markdown to your clipboard.
  5. Use the Sample button to load example HTML and see the tool in action.

What Is Markdown?

Markdown is a lightweight markup language created by John Gruber in 2004. It uses plain text formatting syntax that can be converted to HTML and many other formats. Markdown is designed to be easy to read and write — a Markdown-formatted document looks almost identical to the final rendered output, unlike HTML where tags can obscure the content.

Markdown has become the de facto standard for developer documentation, README files, blog posts, forum comments, and technical writing. Platforms like GitHub, GitLab, Stack Overflow, Reddit, Discord, and Notion all support Markdown natively.

Why Convert HTML to Markdown?

There are many practical reasons to convert HTML to Markdown. If you are migrating a website or blog from a CMS like WordPress to a static site generator (Jekyll, Hugo, Astro, Gatsby), you need to convert your existing HTML content to Markdown files. When scraping or copying content from web pages, converting to Markdown produces clean, readable text without the clutter of HTML tags and attributes.

Markdown is also easier to maintain in version control systems like Git. HTML diffs are noisy and hard to read, while Markdown diffs clearly show what content changed. Documentation teams often prefer Markdown because contributors can focus on writing content rather than wrestling with HTML structure.

HTML vs Markdown Syntax Comparison

The following table shows how common formatting looks in HTML versus Markdown:

  • Headings — HTML uses <h1> through <h6> tags; Markdown uses # through ###### prefixes
  • Bold — HTML uses <strong> or <b>; Markdown uses **text**
  • Italic — HTML uses <em> or <i>; Markdown uses *text*
  • Links — HTML uses <a href="url">text</a>; Markdown uses [text](url)
  • Images — HTML uses <img src="url" alt="text">; Markdown uses ![text](url)
  • Code blocks — HTML uses <pre><code>; Markdown uses triple backticks
  • Lists — HTML uses <ul><li> or <ol><li>; Markdown uses - or 1. prefixes
  • Blockquotes — HTML uses <blockquote>; Markdown uses > prefix

How the Converter Works

This tool uses the browser's built-in DOMParser API to parse your HTML string into a DOM tree. It then recursively walks every node in the tree, converting each element to its Markdown equivalent. Text nodes are preserved as-is, block elements like paragraphs and headings add appropriate newlines and prefix characters, and inline elements like bold and italic wrap their content with the correct Markdown syntax.

Because the conversion runs entirely in your browser, there is no server round-trip, no data transmitted over the network, and no privacy concern. The DOMParser is also highly fault-tolerant — it handles malformed HTML gracefully, automatically closing unclosed tags and normalizing the document structure before conversion begins.

Supported Elements

The converter handles all common HTML elements that have Markdown equivalents:

  • Block elements — headings (h1-h6), paragraphs (p), blockquotes, horizontal rules (hr), pre/code blocks, ordered lists (ol), unordered lists (ul), and tables
  • Inline elements — strong/b (bold), em/i (italic), del/s (strikethrough), a (links), img (images), code (inline code), and br (line breaks)
  • Structural elements — div, span, section, article, header, footer, nav, and aside are traversed transparently, with their content converted normally

Reference-Style Links

Markdown supports two link formats. Inline links place the URL immediately after the text: [text](url). Reference-style links separate the URL from the text: [text][1] in the body, with [1]: url listed at the bottom of the document. Reference-style links produce cleaner, more readable Markdown — especially in documents with many links. Enable the "Reference-style links" checkbox to use this format.

Common Use Cases

  • CMS migration — Convert WordPress, Drupal, or Joomla HTML content to Markdown for static site generators
  • Documentation — Turn HTML docs into Markdown for GitHub wikis, README files, or MkDocs sites
  • Content cleanup — Strip HTML formatting and produce clean, readable plain text with structure
  • Email to Markdown — Convert HTML email content to Markdown for archiving or repurposing
  • Web scraping — Clean up scraped HTML content into structured Markdown documents

Limitations and Unsupported Elements

Some HTML constructs have no Markdown equivalent. Complex tables with merged cells (colspan, rowspan), embedded forms, iframes, and interactive elements like <details>/<summary> are either simplified or their text content is extracted without formatting. CSS styling and class attributes are intentionally stripped — Markdown is a content format, not a presentation format. If your HTML relies heavily on these features, you may need to manually edit the converted output.

Related Tools

Convert Markdown back to HTML with the Markdown Preview. Format raw HTML with the HTML Beautifier. Encode special characters with the HTML Entity Encoder. Compare two documents side by side with the Diff Checker.

Frequently Asked Questions

What HTML elements does this converter support?
This tool converts headings (h1-h6), paragraphs, bold (strong/b), italic (em/i), strikethrough (del/s), links, images, ordered and unordered lists, code blocks, inline code, blockquotes, horizontal rules, line breaks, and tables to their Markdown equivalents.
What are reference-style links in Markdown?
Reference-style links separate the link URL from the text. Instead of [text](url), they use [text][1] in the body and [1]: url at the bottom. This keeps the Markdown cleaner and more readable, especially with many links. Toggle the "Reference-style links" checkbox to enable this format.
Does this tool send my HTML to a server?
No. All conversion happens entirely in your browser using the built-in DOMParser API. Your HTML never leaves your device — no data is transmitted to any server.
Can this tool handle malformed HTML?
Yes. The browser's DOMParser is forgiving and will attempt to parse even imperfect HTML. Missing closing tags and other minor issues are handled gracefully, though the output quality depends on how well the browser can interpret the input.
How does this differ from the Markdown Preview tool?
The Markdown Preview tool converts Markdown to HTML (the opposite direction). This tool converts HTML to Markdown. Use Markdown Preview to write Markdown and see rendered output; use this tool to take existing HTML and generate clean Markdown from it.
Does this tool preserve HTML tables as Markdown tables?
Yes. HTML tables with thead/tbody structure or plain tr/td rows are converted to proper Markdown table syntax with header row, separator row, and data rows using pipe (|) delimiters.
What happens to CSS classes and inline styles?
CSS classes, inline styles, and other HTML attributes (except href on links, src/alt on images) are stripped during conversion. Markdown is a content-focused format and does not support styling — only the semantic content is preserved.
Can I convert an entire web page to Markdown?
You can paste any HTML fragment or full page body content. The converter processes the HTML and extracts the text content with Markdown formatting. For best results, paste the relevant content section rather than the full page with head, scripts, and stylesheets.

AI agent tools available. The CodeTidy MCP Server gives Claude, Cursor, and other AI agents access to 47 developer tools. One command: npx @codetidy/mcp

Drop file to load