Homeโ€บFormattersโ€บCodeโ€บHTML to Markdown Converter

HTML to Markdown Converter

Code

Convert HTML to Markdown instantly in your browser. Handles headings, links, lists, bold, italic, code blocks, and blockquotes. No data uploaded.

What is a HTMLโ†’MD?

An HTML to Markdown formatter converts HTML markup into readable Markdown syntax. It transforms tags like <h1>, <strong>, <a href="...">, <ul>/<li>, and <pre><code> into their Markdown equivalents โ€” #, **, [text](url), - item, and fenced code blocks โ€” producing clean plain text that any Markdown-aware platform can render correctly.

HTML and Markdown solve the same problem โ€” representing formatted text in plain-text files โ€” but Markdown is far easier to write and read. HTML is the native format of the web browser; Markdown is the native format of developer documentation, technical blogs, wikis, and modern headless CMS platforms. As teams migrate content from legacy HTML-heavy CMSes to Markdown-based systems (Notion, Obsidian, Ghost, Hugo, Docusaurus), the need to convert existing HTML content without manual reformatting is a common, practical problem.

The formatter handles the most common prose elements: six levels of headings, bold and italic emphasis, inline and block code, hyperlinks, images, ordered and unordered lists, blockquotes, and horizontal rules. It decodes HTML entities so &amp; becomes & in the output, and strips non-content tags like <script>, <style>, and <meta> automatically. Use it alongside the Markdown to HTML Formatter for the reverse workflow, or the Markdown Formatter to clean up the Markdown output.

How to use this HTMLโ†’MD calculator

  1. Copy the HTML you want to convert โ€” a full page, an article body, or a fragment.
  2. Paste it into the HTML Input field.
  3. The Markdown output updates instantly. Review it for any elements that did not convert as expected.
  4. If links or images are missing, check that the source HTML used proper href and src attributes rather than JavaScript-driven navigation.
  5. Copy the Markdown output and paste it into your target platform, documentation file, or Markdown editor.

Formula & Methodology

The converter applies a sequential rule-based substitution pipeline:

1. <pre><code> blocks are extracted first and converted to fenced code blocks (```).
2. Headings h1โ€“h6 are replaced with the corresponding number of # characters.
3. Block elements: <blockquote>, <hr> are converted.
4. List containers <ul> and <ol> with their <li> items are converted.
5. Inline elements: <strong>, <b>, <em>, <i>, <code>, <a>, <img>, <br>.
6. <p> tags are converted to paragraph breaks.
7. Remaining HTML tags are stripped.
8. HTML entities are decoded.
9. Multiple consecutive blank lines are collapsed to a single blank line.

Before/after example:

Input:
html <h2>Getting Started</h2> <p>Install with <code>npm install zod</code>. See the <a href="/docs/">docs</a>.</p> <ul><li>Fast</li><li>Type-safe</li></ul> 

Output:
```markdown

Frequently Asked Questions

An HTML to Markdown formatter converts HTML markup into Markdown syntax. It translates HTML elements such as headings, bold, italic, links, lists, and code blocks into their Markdown equivalents. The output is clean, readable plain text that renders correctly in any Markdown processor.
Markdown is easier to read and write than HTML, and it is the standard format for documentation sites, README files, blog platforms like Ghost and Hashnode, and CMS editors like Contentful and Sanity. Converting existing HTML content to Markdown lets you move it into these systems without manual reformatting.
The formatter handles headings (h1โ€“h6), paragraphs, bold and italic, inline code and code blocks, links, images, ordered and unordered lists, blockquotes, and horizontal rules. Unsupported elements such as tables, forms, and scripts are stripped or left as text.
Yes. Anchor tags become `[link text](url)` and image tags become `![alt text](src)`. The href and src attributes are preserved. If an image tag has no alt attribute, the Markdown alt text is left empty.
Inline styles and class attributes are stripped. Only the semantic content is preserved. If your HTML relies on CSS classes to convey meaning (e.g. a warning box styled with a class), that visual meaning will not be present in the Markdown output.
Both work. You can paste an entire HTML document (including head and body tags) or just a content fragment. The formatter strips non-content tags like html, head, meta, and script, leaving only the visible content.
No. All conversion happens entirely in your browser. Your HTML is never sent to a server. This makes the tool safe to use with proprietary or sensitive content.
HTML tables are not converted to Markdown tables โ€” they are stripped to their text content. If you need tables in Markdown, use the [Markdown Formatter](/markdown-formatter/) to format your Markdown after pasting the table rows manually, or use a dedicated table formatter.
HTML to Markdown is the reverse operation of Markdown to HTML. You use HTML to Markdown when migrating content out of an HTML-first system into a Markdown-first system. Use the [Markdown to HTML Formatter](/markdown-to-html-formatter/) when you need to render Markdown as HTML for a webpage.
Yes. Common HTML entities are decoded: &amp; becomes &, &lt; becomes <, &gt; becomes >, &quot; becomes ", and &nbsp; becomes a regular space. This prevents entity codes from appearing literally in your Markdown output.
Paste only the relevant section of your HTML rather than the full page. Remove script tags, style blocks, and navigation elements first. Complex nested HTML with div-heavy layouts may not convert cleanly โ€” focus on article or prose content for best results.
Also known as
HTML to Markdownconvert HTML to MDHTML to MD converterHTML markdownstrip HTML to Markdown