Text Tools
HTML to Markdown Converter
Turn CMS exports, documentation pages and pasted markup into clean Markdown — wrappers and inline styling dropped, tables and code blocks kept.
In short
Convert HTML to Markdown online: ATX headings, fenced code blocks and GFM tables with alignment preserved. Strips wrappers and styling. Free and private.
By NaveenKumar T · Updated
- ATX headings & fenced code blocks
- GFM tables with column alignment
- Strikethrough, links and images
Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →
Example
HTML to Markdown: input and output
A documentation fragment as a CMS would export it: a wrapper div, an inline style, an aligned table with markup inside its cells, a code block, a `<del>`, and an analytics `<script>` at the end.
<div class="post"><h2 id="setup">Setting up the CLI</h2>
<p style="margin:0">Download the binary, then run <code>cli init</code>. Full docs are <a href="https://example.com/docs">here</a>.</p>
<table><thead><tr><th>Flag</th><th align="center">Default</th></tr></thead>
<tbody><tr><td><code>--force</code></td><td align="center">false</td></tr>
<tr><td><code>--dry-run</code></td><td align="center"><strong>true</strong></td></tr></tbody></table>
<pre><code>curl -fsSL https://example.com/install.sh | sh
</code></pre>
<p><del>Requires Node 16</del> Requires Node 20.</p>
<script>track("docs")</script></div>## Setting up the CLI
Download the binary, then run `cli init`. Full docs are [here](https://example.com/docs).
| Flag | Default |
| --- | :---: |
| `--force` | false |
| `--dry-run` | **true** |
```
curl -fsSL https://example.com/install.sh | sh
```
~~Requires Node 16~~ Requires Node 20.
The wrapper `<div>`, the `id` on the heading and the inline `style` are gone, the `<script>` is removed rather than pasted in as text, and the table survives as a GFM pipe table whose divider row carries the `:---:` centre alignment from the cells' `align` attributes — with the `<code>` and `<strong>` inside the cells converted too.
Learn more
Why converting HTML to Markdown is the harder direction
Markdown to HTML is a widening conversion — every Markdown construct has an HTML equivalent, so nothing has to be thrown away. HTML to Markdown is the opposite: HTML can express things Markdown simply cannot, and every converter has to decide, element by element, whether to translate, to unwrap, or to give up and leave raw HTML in the output. Get those decisions wrong and you end up with either a document full of `<div>` soup or a document that has quietly lost half its structure.
This page runs turndown, which makes those decisions the way most people expect. Elements with a Markdown equivalent are translated: headings become ATX (`## Heading`, never the underline style, because ATX survives being copied around); `<pre><code>` becomes a fenced block rather than an indented one, so it can carry a language tag; `<em>`, `<strong>`, `<a>`, `<img>`, `<blockquote>`, `<ul>`, `<ol>`, `<hr>` and `<code>` all map cleanly. Elements that are pure presentation — `<div>`, `<span>`, `<font>`, anything carrying only a class or a style — are unwrapped, keeping their contents and discarding themselves. Script, style, noscript and template blocks are removed outright, because their contents are code that would otherwise land in the document as prose.
One extra step happens on the way out: characters that mean something in Markdown are escaped. A literal asterisk in the source HTML becomes `\*` so it does not turn into emphasis when the Markdown is rendered again, and the same goes for underscores, backticks and the leading characters that would start a list or a heading. It looks noisy in the output and it is the difference between a document that round-trips and one that quietly changes meaning.
What survives, what is unwrapped, and what disappears
The table below covers the elements that come up in practice. The short version: semantics survive, presentation does not, and code is removed rather than pasted as text.
| HTML | Becomes | Notes |
|---|---|---|
| `<h1>`–`<h6>` | `#` … `######` | ATX style, never the `===` underline form |
| `<strong>` / `<b>` | `**bold**` | Both spellings map to the same output |
| `<em>` / `<i>` | `*italic*` | |
| `<del>` / `<s>` | `~~strikethrough~~` | A GFM extension, not core Markdown |
| `<a href>` | `text` | Title attributes are kept as `text` |
| `<img src alt>` | `!alt` | Alt text preserved; width/height dropped |
| `<code>` | `` `code` `` | Backtick count adapts if the content has backticks |
| `<pre><code>` | Fenced ```` ``` ```` block | A `language-x` class becomes the fence's info string |
| `<ul>` / `<ol>` / `<li>` | `-` and `1.` lists | Nesting is preserved by indentation |
| `<blockquote>` | `> quoted` | Nested quotes become `>>` |
| `<hr>` | `---` | |
| `<table>` | GFM pipe table | Alignment kept; turn the Tables option off to flatten |
| `<div>`, `<span>`, `<section>` | Unwrapped | Element dropped, contents kept |
| `class`, `id`, `style` | Dropped | Markdown has no way to express them |
| `<script>`, `<style>`, `<noscript>` | Removed | Contents removed too, not pasted as text |
| HTML comments | Removed |
The jobs this tool exists for
Migrating content out of a CMS is the big one. A WordPress, Contentful or Confluence export is HTML wrapped in layers of layout divs and inline styles, and the destination — a docs repository, a static site generator, a wiki — wants Markdown files in version control. Converting strips the scaffolding and leaves content whose diffs are readable, which is the entire reason to move to Markdown in the first place.
Documentation reuse is the second. You want a third-party API's reference table in your own docs, or a Stack Overflow answer in a runbook, or the release notes from a vendor's changelog page in your internal wiki. Copying rendered content into a Markdown file normally means retyping the table by hand; copying the HTML and converting keeps the table, the code blocks and the links intact. The third is preparing text for tools that read Markdown: issue trackers, chat platforms, and increasingly the context you paste into an LLM, where Markdown is both smaller and less ambiguous than the equivalent HTML.
Two practical tips. If the source markup is minified or chaotically indented, running it through the HTML Formatter first makes it far easier to see what you are actually copying — the conversion itself does not care, but you will. And if you only want a fragment, select and copy just that subtree rather than the whole page; converting an entire modern web page includes its navigation, cookie banner and footer as lists of links. When you need the return trip, Markdown to HTML renders the result back with GitHub Flavored Markdown support.
Help
Frequently asked questions
Everything you need to know about the HTML to Markdown.
01How do I convert HTML to Markdown here?
Paste the HTML — a fragment or a whole document — and press Convert. The Markdown appears in the output pane ready to copy or download as a .md file. The conversion runs in your browser with turndown, the library most 'save this page as Markdown' extensions are built on, so the result is the same as what those tools produce.
02What happens to divs, spans, classes and inline styles?
They are dropped and their text is kept. Markdown has no way to express a wrapper element or a colour, so `<div class="card"><p>Hi</p></div>` becomes just `Hi`, and `<span style="color:red">span</span>` becomes `span`. That is usually exactly what you want from a CMS export: the presentational scaffolding disappears and the content survives. Anything with a Markdown equivalent — headings, emphasis, links, images, lists, blockquotes, code, tables, horizontal rules — is converted rather than dropped.
03Are HTML tables converted, or flattened?
Converted, by default, into GitHub Flavored Markdown pipe tables — including the column alignment from each cell's `align` attribute or `text-align` style, which becomes `:---`, `:---:` or `---:` in the divider row. Cell contents are converted too, so a `<strong>` inside a cell comes out as `**bold**`, and any literal pipe characters are escaped so they do not break the table. Turn the Tables option off if your target renderer is strict CommonMark, which has no table syntax at all — the cell text is then emitted as plain text instead.
04What happens to <script> and <style> blocks?
They are removed entirely, along with `<noscript>` and `<template>`. This matters more than it sounds: those elements contain code rather than prose, and a converter that treats them as text pastes your JavaScript and CSS into the middle of the document as a paragraph. Comments are dropped too.
05Does converting to Markdown and back give me the original HTML?
It gives you equivalent HTML, not identical HTML — and that is the point. The round trip is lossy by design: wrappers, classes, ids, styles and any element without a Markdown equivalent are gone after the first leg, so what comes back is the semantic content re-rendered cleanly. Going the other way (Markdown → HTML → Markdown) is nearly lossless, differing only in cosmetic details like list-marker spacing.
Keep working
Related tools
Markdown to HTML
Text Tools
HTML Formatter
Prettier-quality HTML formatting — embedded CSS and JavaScript formatted too, with a live preview one click away.
Markdown Formatter
Canonical CommonMark style — lists, headings, emphasis and tables normalized in one pass.
HTML Escape
Convert text to safe HTML entities and back — <, >, & and quotes handled, named and numeric entities decoded.
String Utility
Text Tools
Epoch Converter
Text Tools