99tools

HTML ↔ Markdown Converter

runs in your browser

Convert HTML to Markdown or Markdown to HTML in your browser, keeping nested lists and tables intact and listing whatever Markdown cannot carry.

Direction
Bullets

Which way round is worked out from what you paste. Markdown cannot carry everything HTML can, and anything dropped is listed beside the output rather than lost quietly.

HTML

Markdown

about this tool

Both directions, and it guesses which

Paste HTML, get Markdown. Paste Markdown, get HTML. Which way round is worked out from the text — a leading tag means HTML, a heading or a bullet on the first line means Markdown — and the switch overrides it when the guess is wrong.

Why this is not a regular expression

Converting HTML is a tree walk, not a search and replace.

Nested lists have to stay nested. Bold inside a link has to stay inside the link. A <pre> block must not be reflowed, however tempting its whitespace looks. Tables have rows and cells that a pattern will happily interleave.

A pattern-based converter handles the common cases and mangles the rest without saying anything, which is the worst way for a converter to fail — the output looks plausible, so nobody checks it. This uses turndown one way and marked the other, which is what everyone else uses, for exactly this reason.

Tables become tables

Most HTML-to-Markdown converters leave a <table> as raw HTML, on the grounds that it is more faithful. It is also useless: the reason you are converting is to stop having HTML.

Tables here become real Markdown tables. Each cell is converted rather than reduced to its text, so a link keeps its address and an image survives; text that only looks like Markdown — a literal *word* in your data — is escaped so it stays literal. Pipes are escaped so the row does not split, and a short row is padded so the columns line up. A cell holding a nested table gets flattened to its text, because a Markdown table cannot hold one — that is a limit of the format, not of the tool.

What cannot come along

Markdown carries less than HTML. The difference here is that each thing lost is named beside the output, and the note says which of two things happened.

Taken out completely, because what they hold is code or graphics rather than prose: <script>, <style>, <noscript>, iframes, inline SVG and form fields.

Kept as words, with the element around them gone: forms, buttons, video and audio — a button's label and a video's fallback line are text the document meant, so removing them would lose more than it saved.

Inline style attributes go, and an image with no alt text becomes a Markdown image with an empty description, easy to miss until someone reads the file.

Going the other way

Markdown allows raw HTML inside it, so the HTML produced from Markdown is run through the same sanitiser the Markdown editor uses. Script tags and event handlers come out, and you are told when something was removed rather than left to wonder.

Nothing is uploaded

Both libraries run in your browser. They are fetched when you open this page rather than shipped to everyone who visits the site.

To tidy HTML before converting it, use the HTML formatter.

questions

Which way round does it go?
Both, and it works out which you want from what you paste. A leading tag means HTML; a heading or a bullet on the first line means Markdown. You can override it with the switch if the guess is wrong.
What happens to things Markdown cannot represent?
Each one is listed beside the output. Script, style and noscript blocks, iframes, inline SVG and form fields are taken out completely, because what they hold is code or graphics rather than prose. A form, a button, a video or an audio element keeps its words and loses the control around it, and the note says which of the two happened. Inline style attributes and images with no alt text get a line too. A converter that loses them silently gives you something that looks right and is not.
Are tables converted properly?
Yes, into real Markdown tables rather than being left as raw HTML, which is what most converters do. Pipes inside a cell are escaped and a short row is padded so the columns still line up. Cell contents are converted properly too, so a link keeps its address and an image survives, and text that only looks like Markdown is escaped rather than turning into markup. A cell holding a nested table is flattened to its text, because a Markdown table cannot hold one.
Why not just use a regular expression?
Because converting HTML is a tree walk, not a search and replace. Nested lists, bold inside a link, a pre block that must not be reflowed — a pattern-based converter gets most of it and mangles the rest without saying so. This uses turndown and marked, the libraries everyone else uses for the same reason.
Is my content sent anywhere?
No. Both libraries run in your browser, so nothing is uploaded. They are fetched when you open this page rather than shipped to everyone who visits the site.
Is the HTML output safe to paste into a page?
It is run through the same sanitiser the Markdown editor uses, so script tags and event handlers are removed and you are told when something was taken out. Markdown allows raw HTML, so this matters more than it sounds.