Typical reasons to go from HTML to Markdown
HTML is how content is published; Markdown is how a lot of it is written and stored. Converting between them comes up when moving a blog from WordPress or another CMS to a static site generator such as Hugo, Jekyll or Astro, when copying documentation from an old intranet page into a Git-based wiki, when saving an article into a notes app like Obsidian, or when preparing web content as clean input for a script or a search index. Markdown keeps the meaningful structure, the headings, emphasis, links and lists, and drops the presentational markup that makes HTML hard to read and edit.
What each element turns into
The conversion runs as you type and follows a fixed set of conventions, chosen to match what most Markdown tools expect:
<h1>to<h6>become#to######headings.<strong>and<b>become**bold**;<em>and<i>become_italic_.<a href>becomes[text](url), keeping atitleattribute if there is one. Links without anhrefbecome plain text.<img>becomes. The image file itself is not touched, so the link points wherever the originalsrcdid.<ul>lists use-as the bullet, and<ol>lists are numbered.<pre><code>becomes a fenced code block between triple backticks. A class such aslanguage-pythonon the code element is kept as the fence's language tag, so syntax highlighting still works.<blockquote>becomes lines starting with>, and<hr>becomes* * *.<br>becomes two trailing spaces and a line break, Markdown's way of writing a hard break.
Elements with no Markdown meaning, such as <div>, <span> and <section>, are unwrapped: their text stays and the tags go. <script>, <style>, <noscript> and <iframe> are removed with everything inside them, which takes care of tracking code, embedded widgets and inline CSS.
Characters that get a backslash
You may notice backslashes in the output that were not in the page, such as 1\. Introduction or \*important\*. This is escaping, and it is correct. If a paragraph in the HTML starts with "1." followed by a space, writing it bare in Markdown would turn it into a numbered list. Literal asterisks, underscores, square brackets and a # at the start of a line are escaped for the same reason, so that the rendered Markdown shows exactly the text the HTML showed.
Getting a clean result from a full web page
The converter does not guess which part of a page is the article. Navigation menus, cookie banners, sidebars and footers are ordinary HTML text, so pasting a whole page source brings all of them along. For a clean result, give it only the content you want:
- Open the page in your browser and right-click the first line of the article, then choose Inspect.
- In the developer tools, find the element that wraps the whole article, often
<article>or<main>. - Right-click it, choose Copy, then Copy outerHTML, and paste that here.
A few other things to keep in mind:
- Relative links stay relative. A link like
/blog/post-2or an imagesrc="img/photo.jpg"is converted as written. If the Markdown will live on a different site, replace them with full URLs. - Email HTML converts poorly. Newsletters are built from nested layout tables, and every
<table>is converted into a Markdown table. The result is a single table with whole sections of text crammed into cells. Copy the inner content of one cell instead of the whole email. - Tables are text-only. Each cell is reduced to its plain text, so links and formatting inside cells are lost, and the first row always becomes the header row.
- HTML comments are dropped.
Checking the output
The quickest way to confirm a conversion is to render it back. Paste the Markdown into Markdown to HTML and look at the preview: headings, lists and code blocks should match the original page structure. If you are converting a Word file rather than a web page, use DOCX to Markdown, which applies the same rules but reads the .docx directly. Nothing you paste here is uploaded; the HTML is parsed and converted by your browser.