Why Convert Between HTML and Markdown?
When migrating content between web CMS, Medium, Notion, Obsidian, and static site generators, raw copied HTML contains heavy inline styles and vendor wrappers. Converting to clean Markdown strips bloated markup, preserving pure semantic content.
Roundtrip Fidelity
- Headings:
<h1>~<h6>Strictly mapped to#through######. - Code Blocks:
<pre><code>Converted into preserved triple-backtick ``` code fences.
Under the hood
The pasted markup is parsed with the browser's own DOMParser, so what gets converted is the tree the browser actually understood rather than the raw text. walk() then recurses that tree: text nodes are returned verbatim, block elements are given a Markdown prefix (headings, paragraphs, list items, quotes), and <pre> blocks are lifted into a separate codeBlocks array first so their contents are never escaped twice. inline() handles the inline layer — strong, emphasis, inline code and links — and markdownToHtml() replays the same map in reverse when you want to go back.
Formats, sizes and other limits
Tables survive only when they are uniformly rectangular: colspan and rowspan are flattened, so a merged cell becomes empty pipes. Attributes, inline styles, <script> and comments are dropped, because Markdown has no place to put them. Lists nested more than about three levels deep lose their indentation cue. And because the browser normalises invalid HTML before conversion, unclosed tags come back as whatever the parser repaired — not as you typed them.
Privacy: nothing is uploaded
The markup you paste is parsed by DOMParser in this tab and converted to text in memory; the page makes no request and there is no endpoint that could receive the source.
Frequently asked questions
What happens to tables?
Rectangular tables become GitHub-flavoured pipe tables. A table with merged cells loses those merges, because Markdown has no colspan or rowspan — the merged cell simply becomes an empty cell.
Why did the inline styles disappear?
Bold, italic, code and links are converted; colours, fonts and spacing are not. Markdown describes structure, not presentation, so anything visual is dropped rather than approximated.
Can I convert back to HTML?
Yes — the reverse direction replays the same element map. It is not lossless though: formatting that the first pass dropped cannot reappear, so a round trip returns the structure, not the original markup.