HTML to Markdown Converter
Strip HTML to clean Markdown — useful for moving content into docs or static sites.
Written by Anil Gautam · Updated
Which HTML tags turn into Markdown?
The converter parses your HTML with the browser's DOMParser, which builds an inert copy of the document: scripts do not run, images are not requested and nothing is uploaded. It then walks the elements and writes Markdown for the ones it knows. Headings h1 to h6 become # to ######, strong and b become double asterisks, em and i single asterisks, del and s double tildes, and code inside running text gets backticks. A pre block becomes a fenced code block, a link becomes [text](href), each line of a blockquote gets a > prefix, and list items get "-" or "1.", "2." and so on. Paragraphs get a blank line after them, hr becomes ---, and tags with no Markdown equivalent, such as div, span, u, mark and sup, contribute only their text.
With the sample in the input box, the h1 becomes "# Hello", the paragraph keeps its bold word as **HTML** and its link as [link](https://oneclickuse.com), and the two list items become "- One" and "- Two", with one blank line between blocks. Runs of three or more line breaks anywhere in the output are squeezed down to a single blank line.
What does HTML to Markdown conversion lose?
Tables have no mapping, so their cell text runs together: a table with the cells Name, Qty, Pen and 2 comes out as NameQtyPen2. Nested lists are flattened, which makes a child item one more sibling of its parent, and an ordered list that starts at 5 is renumbered from 1. A <br> becomes a plain line break, which CommonMark treats as a soft break, so the two lines run together when the Markdown is displayed. The language class on <pre><code class="language-js"> is dropped, so type the language after the opening fence yourself.
Text inside <script> and <style> tags is kept as ordinary text, which means a stray alert(1) or a CSS rule can land in the middle of your Markdown. Paste only the article body, or delete those blocks first. Links and image paths are copied exactly as written, so a relative path like /about or images/chart.png will point somewhere else once the Markdown moves to another site.
Characters that mean something in Markdown are copied without escaping. A paragraph containing 2*3*4 renders in CommonMark as 2, an italic 3, and 4. Bold text with spaces just inside the tags, such as <strong> spaced </strong>, becomes ** spaced **, which CommonMark prints with the asterisks showing. Check the result in the editor or site where the Markdown will live, since renderers differ on these cases. For the reverse direction, use the Markdown to HTML Converter.