Guide
Converting HTML back to Markdown
By Logappradeep · ServiceNow developer
Converting HTML to Markdown is the reverse of what a static site generator does. Instead of rendering lightweight text into tags, you take existing markup, such as a blog post exported from a CMS, a page copied from an internal wiki, or the body of an HTML email, and turn it into plain text with Markdown syntax that is easy to edit, diff and store in Git.
How elements map to Markdown
Most structural HTML has a direct Markdown equivalent:
<h1>through<h6>become one to six#characters.<strong>and<b>become**text**;<em>and<i>become*text*.<a href="/docs">Docs</a>becomes[Docs](/docs).<li>items become lines starting with-for unordered lists or1.for ordered ones.<p>becomes a paragraph separated by a blank line, and<br>becomes a line break.
So <h2>Setup</h2><p>Run <strong>make</strong>.</p> converts to a ## Setup heading followed by the line Run **make**.
What does not survive
Markdown describes document structure, not presentation, so the conversion is lossy by design. Classes, IDs, inline styles, colors, fonts and layout containers such as <div> and <span> have no Markdown form and are dropped. Complex tables with merged cells, forms, iframes and embedded scripts cannot be expressed either. Most converters, and most Markdown renderers, keep such fragments as raw HTML embedded in the Markdown, which is valid but defeats some of the purpose. Expect to tidy the result by hand when the source is a heavily designed page.
Good reasons to convert
- Migrating a WordPress or Confluence page into a docs-as-code repository.
- Turning a rich-text email or newsletter into a plain README or changelog entry.
- Saving web articles as Markdown notes in tools like Obsidian.
- Reducing noisy HTML to plain structure before reviewing changes in a diff.
Pitfalls
Check whitespace and escaping. Characters that mean something in Markdown, such as *, _, # at the start of a line, or a number followed by a period, need a backslash if they appear in ordinary text; otherwise a line like "2024. A good year" might turn into a numbered list. Relative links and image paths copied from a website may break once the content lives somewhere else, so search for ](/ and update them. Finally, pick the flavor your destination expects: GitHub Flavored Markdown supports pipe tables and task lists, while some platforms only accept basic CommonMark.
Conversion in this tool runs in your browser, so pages from private intranets are not uploaded anywhere.