Convert HTML to Markdown
Turn HTML into clean Markdown without uploading it. Drop a file or paste the markup: the conversion runs in this tab.
Drop an .html file here
or
Or paste markup, or paste formatted content copied from a page
Converted in this tab. The file is never uploaded.
Pasting from a live page beats pasting source
Select text on a rendered page and copy it: the clipboard carries the formatted HTML behind the selection, which converts straight to Markdown with its headings and lists intact. Copying from view-source gives you escaped text, which converts to a code block instead.
Everything is sanitized first
HTML from the web is untrusted input. The markup is sanitized before conversion, so scripts, event handlers and inline styles are removed rather than carried into your document.
What survives the trip
Markdown is a much smaller language than HTML, so a conversion is always a narrowing. What matters is knowing which parts narrow and which disappear:
| In the HTML | In the Markdown |
|---|---|
h1-h6 | # to ######, level kept |
strong, b, em, i | **bold** and *italic* |
ul, ol, nested lists | Bullets and numbers, indentation kept |
table | A pipe table, if every row has the same number of cells |
pre and code | A fenced block, language kept when the class names one |
a href | [text](url), relative URLs left as they were |
img | , alt text kept |
blockquote | >, nesting kept |
del, s | ~~struck~~ |
div, span, section | Unwrapped: their contents survive, the tags do not |
style, class, id | Dropped; Markdown has nowhere to put them |
script, iframe, event handlers | Removed by the sanitizer before conversion |
| Colspan and rowspan | Lost: a Markdown table is a plain grid |
The three things that usually go wrong
A page that comes out as one long paragraph. The source
used styled divs where it should have used headings and
lists. Turndown reads structure, not appearance, so text that only looks
like a heading has no heading to convert. Nothing can fix this
automatically: the information was never in the markup.
A table that came out mangled. Markdown tables are a
rectangle: every row the same width, no merged cells, no nested tables.
An HTML table using colspan flattens, and one containing a
list inside a cell will lose the list's line breaks. If the table is the
point of the document, the table generator
is a faster way to rebuild it than fixing the pipes by hand.
Escaped angle brackets everywhere. You copied from
view-source rather than from the page. The clipboard then holds the markup
as text, so the converter correctly treats it as text. Copy from
the rendered page instead, or drop the .html file.
Whole file, or one selection
Dropping an .html file converts the whole document, including
whatever the page's navigation and footer contribute, which for a saved
web page is often most of it. Selecting the part you actually want on the
rendered page and pasting is usually less work than deleting the rest
afterwards.
Either way the file is read in this tab. There is no upload step, which is also why it works with the network off and why a page containing anything private is safe to convert here.
Common questions
- How do I convert HTML to Markdown?
- Drop an .html file onto the box above, or paste the markup into the left pane. The Markdown appears on the right, ready to copy or download.
- Can I paste a whole web page?
- Yes. Copy from the rendered page rather than viewing source and the clipboard carries formatted HTML, which converts directly. Copying from view-source gives you escaped text instead, which converts to a code block.
- What happens to scripts and styles?
- They are removed. The HTML is sanitized before conversion, so scripts, event handlers and inline styles are stripped rather than carried into the output.
- Which elements are supported?
- Headings, paragraphs, lists, tables, links, images, blockquotes, code blocks, and bold, italic and strikethrough. Layout markup such as divs and spans is unwrapped, since Markdown has nothing to map it onto.
- Why did my page come out as one long paragraph?
- Usually because the source used styled divs rather than semantic elements. Turndown reads structure, not appearance, so text that only looks like a heading has no heading to convert.
Sources
- Turndownthe HTML-to-Markdown converter this page runs
- MDN: HTML reference