About HTML to Markdown
HTML is a poor format to keep writing in. If you are moving a blog to a static site, bringing old documentation into a repository, or rescuing an article from a CMS export, you want the words and structure without the tags. Paste the HTML here and you get Markdown that reads like a person wrote it.
It works on partial snippets and on whole saved pages. For a full page, the Main content only option looks for a <main> or <article> element and ignores everything outside it, which removes most of the menus and footers you would otherwise delete by hand.
Your result is plain text that converts back cleanly. For the structures Markdown can express, feeding the output to Markdown to HTML gives you the same structure you started with.
How it works
The HTML is parsed into a tree first, instead of being edited with search and replace, so a list inside a list keeps its depth and a > inside an attribute value cannot end a tag early. Common shortcuts in hand-written HTML are understood, such as <li> items and table cells with no closing tag.
Each element then maps to its Markdown form. <pre> blocks become fences, and a language- class on the code element carries over as the fence language. If the code contains backticks, the fence grows longer than any run inside it. Tables become GitHub tables, taking alignment from an align attribute or a text-align style. Checkboxes in lists become [x] and [ ].
Text is escaped where Markdown would otherwise reinterpret it. A literal asterisk becomes \*, a paragraph that starts with 1. becomes 1\., and a real snake_case_word is left as it is because underscores inside a word are safe. Scripts, styles, the page head, hidden elements and embedded media are skipped, and a javascript: link is reduced to its text.
How to use HTML to Markdown
- Paste a snippet or a whole page into the left pane, use Open file for an
.htmlfile, or press Try an example. - Read the Markdown on the right as it updates.
- For a whole page, open Options and turn on Main content only.
- Press Copy result, or Download .md to save the file.
A snippet with a nested list and a code block
<h2>Setup</h2>
<p>Run <code>make</code>, then see the <a href="https://example.com/docs">docs</a>.</p>
<ol><li>Install<ul><li>Linux only</li></ul></li><li>Test</li></ol>
<pre><code class="language-sh">make test</code></pre>
<script>track()</script>## Setup
Run `make`, then see the [docs](https://example.com/docs).
1. Install
- Linux only
2. Test
```sh
make test
```The bullet is indented three spaces to sit under the text of item 1, which is what makes it nest when parsed again. The language-sh class became the fence language, and the script is gone.
When it helps
- Moving posts from a CMS export into a static site generator that reads Markdown files.
- Bringing a wiki page or an old HTML manual into a Git repository, where text diffs are readable.
- Saving a web page's source and keeping just the article as notes, using Main content only.
- Rewriting a messy table from a web page as a GitHub table for a README.
Tips for a better result
- If a page has neither
<main>nor<article>, the option has nothing to go on and the whole body is converted. Copying only the section you want from your browser's inspector usually works better. - Links and images keep their addresses exactly as written. If the page used relative paths such as
/images/a.png, they will need updating in their new home, and the images themselves are not fetched. - HTML pasted from Microsoft Word carries a lot of empty spans. They convert to nothing, but check for leftover line breaks. Bold spans made only with CSS will lose their weight, because styles are not read.
Good to know
- Markdown has no merged cells, so a
colspanorrowspancell takes one column and the table will need fixing by hand. - A table with no header row gets an empty header, because a Markdown table must have one.
- Tables nested inside tables, and block content in cells, are flattened into one line.
- Colors, fonts, classes and other styling are lost, as is anything only CSS makes bold, italic or hidden.
- Video, audio, iframes, SVG and form fields are removed. The text on buttons and labels is kept as plain text.
- It reads the HTML you give it and does not run JavaScript, so paste the rendered source if a page builds its content in the browser.
Questions people ask
Why are there backslashes in my Markdown?
They stop ordinary characters from turning into formatting. Without one, "2 * 3 * 4" could become italic text and "[note]" could look like a link. They are invisible once rendered, and removing them is safe wherever the character could not be misread.
How do I convert a whole web page without the menus?
Paste the page source, then turn on Main content only under Options. It uses the page's <main> element, or its first <article> if there is no main, so results depend on how the page was built. Pages using only generic <div> elements need trimming by hand.
Will a line break in the HTML become a line break in Markdown?
Only a <br> will, written as two trailing spaces so the break survives. Ordinary newlines in HTML source are just whitespace to a browser, so they collapse into a single space here too. A <pre> block is the exception, and it keeps every line as it was.
Can it convert a URL directly?
No. It works only on HTML you paste or open, and it never fetches anything. Use your browser's View Source or Save Page As, then bring that here.
What to use next
- HTML to Text: if you want only the words, with no Markdown syntax at all
- HTML Beautifier: to read tangled source first and find the part worth converting
- Markdown Previewer: to clean up the converted text while watching how it renders
- DOCX to Markdown: if your source is a Word file and not a web page
Last reviewed . Read our editorial policy.