HTML to Markdown
Paste HTML and get Markdown back: headings, paragraphs, emphasis, links, images, bullet and numbered lists (nested lists stay nested), inline code, fenced code blocks that keep their language, blockquotes and pipe tables. The HTML is parsed by your browser's own parser into an inert document, so scripts and event handlers in pasted markup never run, and nothing you paste is uploaded.
How to use the HTML to Markdown
- Paste HTML into the left box: a whole saved page, a fragment copied from a CMS, or the output of a rich-text editor.
- Click Convert. The Markdown appears on the right, ready to select and copy.
- Click Load example to convert a small document with headings, a link, a list and a JavaScript code block.
Only the document body is converted, so a <title> or anything else in <head> is ignored.
Elements that have no Markdown equivalent, such as <div>, <span> and
<section>, are unwrapped: their text is kept and the tag is dropped. <script>,
<style>, <noscript>, <template> and <iframe> are removed
together with their contents, and HTML comments are dropped.
Attributes are discarded except the ones Markdown can express: href on links, src and
alt on images, the start number of an ordered list, and a language-* or lang-*
class on a code block, which becomes the fence language (```javascript).
How each HTML element maps to Markdown
| HTML | Markdown |
|---|---|
<h1> to <h6> | # to ###### |
<strong>, <b> | **bold** |
<em>, <i> | *italic* |
<del>, <s>, <strike> | ~~struck~~ (GitHub-style strikethrough) |
<code> inside text | Backticks. If the code itself contains a backtick, a longer run is used: a`b becomes ``a`b``. |
<pre> | A fenced block. If the code contains ```, the fence grows to ```` so the block cannot end early. Blank lines inside the code are kept. |
<a href> | [text](url); a URL with spaces or parentheses is wrapped as [t](<my file.html>). A link without href keeps only its text. |
<img> |  |
<ul>, <ol> | - item and 1. item. A nested list is indented to line up with its parent item's text: 2 spaces under - , 3 under 1. , as CommonMark requires. |
<blockquote> | > on every line |
<table> | A GitHub-style pipe table; the first row is the header and a | inside a cell is written as \|. |
<br>, <hr> | Two trailing spaces (a hard line break), and --- |
Plain text is escaped where Markdown would otherwise read it as formatting: backslashes, backticks, *,
[, ], and an underscore that is not inside a word. So 2 * 3 = 6 and snake_case and _x_
becomes 2 \* 3 = 6 and snake_case and \_x\_. snake_case stays as it is because CommonMark never treats an
underscore between two letters or digits as emphasis. Runs of spaces and line breaks in normal text collapse to one
space, which is how a browser displays them anyway; whitespace inside <pre> is kept exactly.
Common use cases
- Moving a blog to a static site generator. Posts exported from WordPress or another CMS are HTML; Hugo, Jekyll, Astro and Docusaurus want Markdown files.
- Copying documentation into a README or an issue. Paste the HTML of a docs section and keep its headings, code blocks and tables instead of retyping them.
- Knowledge bases and note apps. Rich-text editor output (TinyMCE, CKEditor, Google Docs exports) becomes Markdown for Obsidian, a wiki or a Git repository.
- Feeding content to an LLM. Markdown carries the same structure as HTML with far fewer tokens than tags and attributes.
Links are copied exactly as they appear in href. Relative links such as /docs/setup/ stay relative,
so check them if the Markdown will live on a different site.
Worked example
This is the input behind Load example:
<h1>Sample Document</h1><p>This is a <strong>sample</strong> with a <a href="https://codeswap.net">link</a>.</p><h2>Features</h2><ul><li>Headings</li><li>Lists</li><li><code>Inline code</code></li></ul><pre><code class="language-javascript">function hello() { return "world"; }</code></pre>
and the Markdown it produces:
# Sample Document
This is a **sample** with a [link](https://codeswap.net).
## Features
- Headings
- Lists
- `Inline code`
```javascript
function hello() { return "world"; }
```
A nested list, <ul><li>One<ul><li>Two</li></ul></li></ul>, becomes
- One
- Two
and a table whose first cell contains a pipe, <table><tr><th>a|b</th><th>c</th></tr><tr><td>1</td><td>2</td></tr></table>, becomes
| a\|b | c |
| --- | --- |
| 1 | 2 | What it does not convert
- Table layout.
colspanandrowspanare ignored (each cell becomes one column), column alignment is not carried over, and a list or paragraph inside a cell is flattened onto one line. Pipe tables cannot hold block content. - Line-start markers in text. A paragraph whose text begins with
#,>or1.is not escaped, so it may read as a heading, quote or list. - Definition lists, forms, iframes and embeds. Definition lists and forms are unwrapped to text. Iframes, objects and embeds are removed.
- Styling. Colors, fonts, classes and inline styles are dropped. Markdown has no way to express them.