HTML ↔ Markdown Converter

Convert between HTML and Markdown in either direction. 100% client-side.

HTML Input
Markdown Output
Paste HTML above to convert it to Markdown.

How to Use the HTML Markdown Converter

  1. Choose a direction — select "HTML to Markdown" or "Markdown to HTML" using the chips above the editor.
  2. Paste your content into the input area on the left (or top on mobile).
  3. View the result — the converted output appears instantly on the right as you type.
  4. Copy or download — use the buttons above the output pane to copy to clipboard or download the result file.

What This Tool Does

This converter transforms HTML markup into clean Markdown syntax, and vice versa. When converting HTML to Markdown, it uses the browser's built-in DOMParser API to create a proper document tree from your HTML, then recursively walks each node to produce equivalent Markdown. This approach is far more reliable than regex-based conversion because it correctly handles nested elements, malformed HTML, and edge cases that string manipulation would miss.

Features

  • Bidirectional conversion — switch between HTML-to-Markdown and Markdown-to-HTML with a single click
  • DOM-based parsing — uses the browser's native DOMParser for accurate, standards-compliant HTML parsing
  • Comprehensive element support — headings, paragraphs, bold, italic, links, images, lists, code blocks, blockquotes, tables, horizontal rules, and strikethrough
  • Live conversion — output updates as you type with a 150ms debounce for smooth performance
  • Privacy — everything runs locally in your browser with zero server communication
  • Clean output — produces well-formatted Markdown without unnecessary whitespace or artifacts

HTML to Markdown Conversion Details

The HTML-to-Markdown converter processes each HTML element type specifically. Heading tags (h1 through h6) are converted to the corresponding number of # symbols. Strong and bold tags become ** wrappers. Emphasis and italic tags become * wrappers. Anchor tags are converted to [text](url) link syntax. Image tags become ![alt](src). Unordered list items get - prefixes, ordered list items get numbered prefixes, and nested lists are indented appropriately.

Markdown to HTML Conversion Details

When converting Markdown to HTML, the tool uses an inline parser that processes block-level structures first, such as headings, code blocks, lists, blockquotes, and paragraphs, then handles inline formatting within each block. The result is clean, semantic HTML that uses proper elements like <strong> instead of <b>, <em> instead of <i>, and properly nested list structures. Code blocks include language class attributes for compatibility with syntax highlighting libraries.

Use Cases

Developers use this tool to convert HTML email templates into Markdown for documentation, to transform CMS content into Markdown for static site generators like Jekyll, Hugo, or Gatsby, and to migrate content between platforms. Technical writers convert Markdown documentation into HTML for embedding in web pages or email newsletters. Content managers use it to move articles between WordPress (HTML) and GitHub wikis (Markdown). The bidirectional capability makes it especially useful when you need to work across both formats frequently. To preview your Markdown output before publishing, use our Markdown Preview. You can also format any JSON embedded in your HTML with the JSON Formatter, or count words and estimate reading time with the Word Counter.

Handling Edge Cases

The converter gracefully handles several tricky scenarios. Nested formatting like bold text inside a link produces [**bold link**](url). Code blocks that contain HTML-like content are preserved as literal text. Empty elements are skipped to avoid producing artifacts. Self-closing tags like <br> and <hr> are converted to their Markdown equivalents. Tables with varying column counts are padded appropriately. When converting Markdown to HTML, ambiguous syntax like underscores in the middle of words is handled correctly to avoid false italic detection.

Frequently Asked Questions

The converter uses the browser's built-in DOMParser to parse your HTML into a document tree. It then walks through each node recursively, converting HTML elements to their Markdown equivalents: h1 becomes #, strong becomes **, a becomes [text](url), and so on. This approach handles real-world HTML reliably because it leverages the browser's own HTML parser.
No. This converter runs 100% in your browser using JavaScript. Your HTML and Markdown never leave your machine. There is no server-side processing, no logging, and no data collection.
The converter handles headings (h1-h6), paragraphs, bold (strong/b), italic (em/i), links (a), images (img), unordered lists (ul/li), ordered lists (ol/li), code and pre elements, blockquotes, horizontal rules, line breaks, tables, and strikethrough (del/s). Unsupported or custom elements are converted to their text content.
Yes. Click the Markdown to HTML chip to switch direction. The tool includes a built-in Markdown parser that converts your Markdown text into clean HTML. It supports headings, bold, italic, code blocks, links, images, lists, blockquotes, tables, and horizontal rules.
Yes. The converter recursively processes all child nodes, so nested structures like lists inside blockquotes, bold text inside links, and code inside paragraphs are all handled correctly. The DOMParser ensures that even malformed HTML is parsed gracefully.