StringMash.com

HTML to Markdown

Pull readable Markdown out of a page, and lose the parts Markdown can't hold.

Conversion
104 characters
Updates as you type
Markers escaped

Using the converter

Paste HTML on the left and Markdown appears on the right. Swap the boxes to go back the other way.

Script and style elements are dropped rather than converted, because their contents are code that would otherwise land in your document as text. Markdown's own markers are escaped in the output, so an asterisk in the HTML comes out as \* and doesn't turn into emphasis on the way back.

This direction loses things

HTML can say more than Markdown can. A span with a class, a nested table, a definition list, an inline style, an id used as an anchor target: none of these has a Markdown spelling, so the converter keeps the text and drops the wrapper.

Whitespace goes too. HTML collapses runs of spaces when it renders, so this does the same, and a document that relied on preformatted spacing outside a pre element won't come back the same. Text inside a pre element keeps its spacing and blank lines.

Markdown was designed around that trade. Gruber's stated goal was that the source should read as plain text, so he left out whatever can't be written plainly.

Aaron Swartz wrote the first one

Markdown came out of a collaboration between John Gruber and Aaron Swartz in 2004. Swartz, then 17, worked on the syntax with Gruber and wrote html2text, a Python script that did exactly what this page does.

It turned a web page into plain text that was also valid Markdown. His script lives on as the html2text package on PyPI, which still credits him and last released in April 2025.

Swartz also wrote atx, the heading format Markdown borrowed, and worked on RSS 1.0 and the early Creative Commons licences. He died in 2013, aged 26, while facing federal charges over bulk-downloading academic papers from JSTOR.

Related conversions

Markdown to HTML is the forward direction, and it explains why the two formats disagree about so much. XML to JSON uses the same tag parser underneath, pointed at data rather than at prose.

Text rescued from a web page often needs line breaks removed before it reads properly.

Questions

How do I convert HTML to Markdown?

Paste the HTML above and copy the Markdown. It runs in your browser, so nothing is sent anywhere.

What gets lost?

Anything Markdown can't express: classes, ids, inline styles, spans, nested tables and definition lists. The text inside them is kept and the wrapper is dropped.

Are script and style tags converted?

No, they're dropped. Their contents are code, and converting them would drop JavaScript into your document as prose.

Why are there backslashes in the output?

Markdown's markers are escaped, so a literal asterisk in the HTML doesn't turn into emphasis when the Markdown is rendered. A paragraph that starts with # or 1. gets one too. Without it, the text would come back as a heading or a list.

Sources

Added . Last updated and reviewed . What's new