Skip to content
HTML to Markdown
Tools

HTML to Markdown

Mpya

Convert HTML to clean Markdown — pastes, imports files, and handles lists, tables and code.

HTML Input 0 words
Markdown Output 0 words

Runs entirely in your browser. Nothing is uploaded.

Why convert HTML to Markdown?

Markdown has become the standard plain-text format for technical writing, documentation, and developer-facing content. Unlike HTML, it reads naturally in raw form, works in any text editor, version-controls cleanly with Git, and is natively supported by platforms like GitHub, GitLab, Notion, Obsidian, and every major static site generator. When content already exists in HTML — from a CMS, a scraped article, an email, or a legacy documentation platform — converting it to Markdown unlocks all of these workflows without manual reformatting.

In 2026, there's an additional practical reason: AI and LLM pipelines strongly prefer Markdown over raw HTML. Research shows that clean Markdown reduces token usage by 68–87% compared to raw HTML for the same content. When feeding documentation into a retrieval-augmented generation (RAG) system, or preparing training data for a fine-tuned model, converting HTML to Markdown first is now standard practice. Perplexity, ChatGPT, and Gemini all internally convert web content to Markdown-like representations before processing — so giving them Markdown directly skips a lossy conversion step.

How DOM-based HTML to Markdown conversion works

Rather than applying fragile regular expressions to raw HTML strings — an approach that breaks on malformed tags, nested elements, and edge cases — this tool parses your HTML into a real DOM tree using the browser's built-in parser. It then walks each node recursively, mapping element types to their Markdown equivalents. Block elements (headings, paragraphs, lists, code blocks) get double newlines so the Markdown renders correctly. Inline elements (bold, italic, code, links) produce their Markdown syntax inline within the surrounding content.

This DOM-based approach is the same technique used by Turndown.js, the leading HTML-to-Markdown JavaScript library with over 2.5 million weekly npm downloads. It handles edge cases that regex-based converters miss: nested lists inside blockquotes, code inside list items, anchor tags wrapping images, and deeply nested table cells. Unknown structural HTML elements like div, section, and article simply pass through their children, so no content is silently dropped.

Common use cases: CMS migration, Notion, GitHub docs

CMS migration is the most common professional use case. Teams moving from WordPress, Confluence, SharePoint, or Ghost to a modern Markdown-based platform use HTML-to-Markdown conversion to process exported content. WordPress's export gives you HTML content blocks; Confluence exports pages as HTML or XHTML. Both convert cleanly. The Markdown files are then committed to a Git repository, imported into Notion via its Markdown import feature, or fed into a static site generator like Docusaurus, MkDocs, or Astro.

Personal knowledge management is another common use case. Tools like Obsidian and Logseq are built around Markdown files. When you find an article or documentation page you want to archive in your knowledge base, this converter lets you paste the page HTML and get a clean Markdown file in seconds — preserving structure without the noise of raw HTML tags. The word count display helps confirm no content was dropped during conversion.

Pandoc vs browser-based converters: when to use which

Pandoc is the gold standard for document conversion in professional pipelines — a command-line tool that converts between dozens of formats including HTML to Markdown, Markdown to PDF, and many others. It handles edge cases like definition lists, footnotes, and complex nested structures, and supports more output flavors than any JavaScript converter: MultiMarkdown, Pandoc Markdown, AsciiDoc, reStructuredText, and more. If you're building an automated batch-conversion pipeline on a server, Pandoc is the right choice.

For one-off conversions, quick content migrations, or work with sensitive material that shouldn't leave your device, a browser-based converter is faster and more practical. Nothing to install, no command line to learn, instant results. This tool covers the vast majority of real-world HTML structures — headings, paragraphs, lists, tables, code blocks, links, images — making it the practical choice for everyday HTML-to-Markdown needs. Markdownify and h2m are solid npm alternatives if you need to script conversions in Node, but they require a project setup that this tool skips entirely.

Markdown syntax reference and output compatibility

Key Markdown conventions this tool follows: headings use # through ###### for h1–h6, bold wraps text in **double asterisks**, italic in *single asterisks*, inline code in backticks, and fenced code blocks in triple backticks with an optional language identifier. Links follow the pattern [text](url) and images use ![alt text](src url). Unordered lists use a dash prefix; ordered lists use numbers followed by a period. Blockquotes prefix each line with >.

Tables use pipe characters to separate columns, with a separator row of dashes (and optional colons for alignment) after the header row. Strikethrough wraps text in ~~double tildes~~. The output follows CommonMark with GitHub Flavored Markdown (GFM) extensions, making it compatible with GitHub, GitLab, VS Code preview, Notion, Obsidian, and virtually every modern Markdown renderer. If you see rendering differences between platforms, they're almost always due to the platform using a non-standard Markdown flavor rather than an issue with the output.

Privacy, no limits, and mobile support

This HTML to Markdown converter runs 100% in your browser. Nothing is uploaded to a server, nothing is logged, and no account is needed. That means it's safe to paste confidential documentation, internal wikis, or client content — it never leaves your device. You can even disconnect from the internet after the page loads and it keeps working, which is the simplest proof that no server is involved.

There's no file size limit, no daily conversion quota, and no paywall. Online converters that process files server-side, like some Pandoc web wrappers or document conversion APIs, often cap file sizes at 1–5 MB or limit free users to a few conversions per day. This tool has none of those restrictions. It also works on iPhone and Android — paste HTML from your phone's browser, convert it, and copy the Markdown result directly into Notion, Obsidian, or any other app.

HTML-to-Markdown is a lossy conversion — what that means in practice

It is easy to assume that converting between two document formats is a reversible process, but HTML-to-Markdown conversion is fundamentally lossy. HTML is a superset of what Markdown can express. A <span style="color: red"> element has no Markdown equivalent — the text survives the conversion but the colour instruction is silently dropped. A <table> with merged cells (colspan or rowspan) can be approximated as a GFM pipe table at best, but the merge semantics disappear entirely. Any element whose meaning lives in a CSS class, an inline style, or a non-standard attribute — tooltips, ARIA labels, data attributes — simply does not exist in Markdown's vocabulary and is discarded during traversal. This is a deliberate design choice, not a bug: Markdown was designed to represent prose structure, not visual layout.

The inverse direction — Markdown-to-HTML — is completely lossless within the spec. Every valid Markdown construct has a precisely defined HTML output: a # heading always becomes <h1>, **text** always becomes <strong>text</strong>, a fenced code block always becomes <pre><code>. This asymmetry matters when you are choosing a workflow. Converting HTML to Markdown and then back to HTML does not round-trip to the original; it produces a semantically simplified version. That simplified version is often exactly what you want — clean, portable, readable prose — but you should not treat it as a faithful replica of the source. Always keep the original HTML if lossless archiving is the goal.

There is also the whitespace normalization problem. HTML collapses all whitespace: dozens of newlines and spaces in the source render as a single space character in the browser. Markdown, by contrast, is whitespace-sensitive: two trailing spaces mean a hard line break, a blank line means a paragraph boundary. A DOM-based converter infers paragraph structure from block-level elements — <p>, <div>, <br>, <li> — rather than from the raw whitespace in the HTML source, which is the only reliable way to reconstruct the intended document flow. Regex-based converters that work on raw text rather than a parsed DOM frequently collapse or multiply blank lines because they have no model of block boundaries.

Why HTML-to-Markdown conversion is essential in modern workflows

Content migration is the use case that drives most production usage. Moving a large WordPress installation or a Confluence wiki to a Markdown-based platform — Hugo, Astro, Docusaurus, MkDocs — means converting thousands of HTML posts to Markdown files. Automation tools like wordpress-export-to-markdown and WPXML-to-Markdown parse the WordPress export XML, extract the HTML content field for each post, run it through a converter such as Turndown.js, and write the result to .md files. Teams doing Confluence migrations use a similar pipeline: export the space as HTML, iterate over the exported files, and pipe each through a converter. The quality of the Markdown output determines how much manual cleanup is required afterward, so choosing a DOM-based converter over a regex-based one pays dividends at scale.

AI and LLM context preparation has become equally important. Web pages fed to language models as raw HTML waste a significant fraction of the available context window on tag noise. A paragraph inside a <div class="article-body"> with a dozen nested wrapper elements costs far more tokens than the same paragraph in plain Markdown. Tools like Jina Reader (r.jina.ai), Firecrawl, and Trafilatura have built their entire value proposition around converting arbitrary web pages to clean Markdown before delivering them to an AI pipeline. Research published in 2024 quantified the difference: Markdown reduces token usage by 68–87% compared to raw HTML for equivalent content, which directly reduces API cost and increases the effective context available for reasoning. For retrieval-augmented generation (RAG) pipelines that chunk and embed web content, clean Markdown also produces more semantically coherent chunks because paragraph and heading boundaries in Markdown map directly to meaningful document structure, rather than to arbitrary div nesting.

Documentation modernization is a third wave of adoption. Legacy enterprise documentation living in Confluence, SharePoint, or old static HTML sites is increasingly being migrated to developer-friendly systems: Notion for non-technical teams, Obsidian for personal knowledge management, or a Git repository for engineering docs. HTML-to-Markdown conversion is the linchpin of that migration. Rich HTML emails present a related use case: converting a formatted email thread to Markdown lets you include it as a ticket comment, a meeting note, or a wiki entry without the visual clutter of raw HTML tags or the opaque base-64 blobs that raw email sources contain. In each of these contexts the converter is not the end product — it is the translation layer that unlocks a downstream workflow.

Turndown.js, Pandoc, and the HTML-to-Markdown library landscape

Turndown.js is the dominant JavaScript library for HTML-to-Markdown conversion, with more than 2.5 million weekly npm downloads and over 10,800 GitHub stars as of 2026. It works by building a DOM tree from the input HTML and walking each node to emit a Markdown equivalent. Its behaviour is highly configurable: headingStyle controls whether headings use ATX style (# Heading) or Setext style (Heading =======), bulletListMarker sets whether unordered list items use -, *, or +, codeBlockStyle switches between fenced triple-backtick blocks and four-space-indented blocks, and linkStyle chooses between inline links ([text](url)) and reference-style links collected at the bottom of the document. Plugins extend Turndown with additional rules — strikethrough, tables (via the turndown-plugin-gfm package), task lists — keeping the core small while supporting the full GFM feature set when needed. The same DOM-traversal architecture that makes Turndown reliable in a Node environment is what makes a browser-based converter reliable: the browser's own HTML parser, which handles malformed and real-world HTML far better than any hand-written parser, does the heavy lifting.

Pandoc, written in Haskell by John MacFarlane, is the gold standard for document format conversion at the academic and professional level. It converts between more than 40 formats: HTML to Markdown, Word (.docx) to Markdown, LaTeX to HTML, Markdown to PDF, EPUB, and dozens more. Its extended Markdown dialect supports footnotes, definition lists, citation syntax, and LaTeX math blocks — features that are out of scope for CommonMark or GFM. For converting HTML documents that contain academic citations, chemical formulae, or cross-referenced footnotes, Pandoc has no peer. The trade-off is operational: Pandoc requires installation, a Haskell runtime, and command-line usage. It is the right tool for a server-side batch conversion pipeline, not for quick ad-hoc work in a browser.

The Python ecosystem has html2text, originally written by Aaron Swartz and later maintained by the open-source community. It is a simple, dependency-light library that converts HTML to Markdown-formatted text and is widely used in Python scraping and content-processing scripts. It produces readable output for standard prose but handles edge cases such as nested lists, complex tables, and code blocks less gracefully than Turndown or Pandoc. A critical distinction separates all three of these libraries from tools that merely strip HTML tags: strip_tags() in PHP or element.innerText in JavaScript discard all formatting and return flat plain text — no headings, no emphasis, no lists, no links. A proper HTML-to-Markdown converter preserves all of that structure, encoding it in Markdown syntax rather than HTML tags. The distinction matters enormously when the output will be rendered in a Markdown-aware environment: stripping tags produces an undifferentiated wall of text, while a real converter produces a document whose hierarchy is immediately readable and renderable.

Frequently asked questions

What HTML elements does this converter support?

The converter handles headings (h1–h6), paragraphs, bold, italic, strikethrough, inline code, fenced code blocks, blockquotes, horizontal rules, links, images, ordered lists, unordered lists, nested lists, and tables — covering the full CommonMark and GitHub Flavored Markdown (GFM) feature set. Unknown structural elements like div, section, and article pass through their children transparently so no content is ever lost. Most real-world HTML — from a CMS export, a scraped article, or a documentation page — converts cleanly without any post-processing needed on your end.

How is this different from Pandoc or Turndown.js?

Pandoc is a powerful command-line converter but needs installation, a terminal, and knowledge of its flags. It's the right tool for automated server-side pipelines but overkill for a one-off conversion. Turndown.js is the most-used JavaScript library for HTML-to-Markdown work — over 2.5 million weekly npm downloads, 10,800+ GitHub stars — and this tool uses the same DOM-based parsing approach that makes Turndown reliable. The difference is that everything runs in your browser: no install, no command line, no server round-trip, and no files leave your device. Turndown requires a Node project setup; this doesn't.

Why convert HTML to Markdown?

Markdown is the standard plain-text format for technical writing, documentation, and content management. Converting HTML to Markdown lets you import content into Notion or Obsidian, commit it to a Git repository alongside code, publish it via static site generators like Astro, Hugo, or Jekyll, or feed it into AI models and LLMs. Research published in 2024 shows Markdown reduces token usage by 68–87% compared to raw HTML when used with large language models — a real cost and accuracy difference when building RAG pipelines or preparing fine-tuning datasets.

Can I use this for CMS migration?

Yes — CMS migration is one of the most common professional use cases. Paste HTML exported from WordPress, Confluence, SharePoint, Ghost, or any other platform and get clean Markdown you can import into a new system. WordPress's export gives you HTML content blocks; Confluence exports pages as HTML or XHTML — both convert cleanly. For best results, paste just the content body rather than the full page HTML including navigation and footer. Teams have used browser-based HTML-to-Markdown conversion to migrate 150–200-page documentation sites in under two days, without touching the command line.

How are HTML tables converted to Markdown?

Tables convert to GitHub Flavored Markdown (GFM) pipe-table format, with a separator row of dashes after the header row. That format works in GitHub, GitLab, VS Code preview, Notion, Obsidian, Docusaurus, and virtually all modern Markdown renderers. Nested tables are flattened because standard Markdown doesn't support them natively. Column alignment — left, center, right via the align attribute or CSS text-align — is preserved using colon placement in the separator row (e.g. :--- for left, :---: for center, ---: for right).

Does the converter work offline?

Yes. Conversion happens entirely in your browser using the built-in DOM parser — no files are uploaded and no internet connection is required after the page loads. This makes it safe to use with confidential HTML such as internal documentation, proprietary API references, or client work that shouldn't leave your device. You can verify this: open browser DevTools, go to the Network tab, and confirm zero network requests fire when you paste HTML and trigger a conversion. Nothing leaves your machine.

What does 'Trim extra whitespace' do?

It removes trailing spaces and tabs from every line of the Markdown output, and collapses multiple consecutive blank lines into a single blank line. This keeps files clean and avoids invisible whitespace that can affect rendering in strict Markdown parsers — especially GitHub's, which highlights trailing whitespace as a lint issue. It also makes the output easier to drop into documentation tools that run whitespace checks. The option is safe to leave on in almost all cases. Only very rarely does trailing whitespace carry semantic meaning.

Will nested lists convert correctly?

Yes. Nested ul and ol elements are processed recursively and each level is correctly indented in the Markdown output. Mixed nesting — ordered lists inside unordered lists, or vice versa — is also handled correctly. A three-level-deep unordered list inside an ordered list, for example, gets proper four-space indentation at each level, which is the CommonMark standard. This is one of the edge cases where regex-based converters frequently fail and produce broken Markdown. DOM-based parsing handles it reliably.

What Markdown flavor does the output use?

The output follows CommonMark with GitHub Flavored Markdown (GFM) extensions for tables and strikethrough. CommonMark is the standardized spec used by most platforms, and GFM adds the pipe-table syntax and ~~ strikethrough that GitHub, GitLab, and VS Code all support. This makes the output compatible with GitHub, GitLab, VS Code, Notion, Obsidian, Docusaurus, MkDocs, and most modern Markdown renderers. If you need strict CommonMark without GFM extensions, tables are the only element that would differ — everything else is identical.

Can I convert a full webpage to Markdown?

You can paste any HTML fragment or full page body. For best results paste just the main content area — not the full document with nav, sidebar, and footer — so the output stays focused on meaningful content. Most developers copy just the article or documentation div from the browser DevTools Elements panel (right-click → Copy → Copy outerHTML). That gives clean content HTML without the structural page chrome. The converter handles full-page HTML too but the output will include navigation text converted as a flat list of links, which usually isn't what you want.

Why is Markdown better than HTML for AI and LLMs in 2026?

AI systems like Perplexity, ChatGPT, and Gemini now read, chunk, and reuse web content to generate answers. Markdown is their preferred input format because it strips away HTML structure tags that consume tokens without adding semantic meaning. A paragraph wrapped in <p class="article-body"> tags costs more tokens than the same paragraph in plain Markdown. Research published in 2024 shows Markdown reduces token usage by 68–87% compared to raw HTML for the same content — which directly reduces API cost and improves signal-to-noise for retrieval-augmented generation (RAG) pipelines.

How are inline code and code blocks handled?

Inline code elements (code tags not inside pre) are wrapped in single backticks. Code blocks (pre > code elements) are wrapped in triple-backtick fenced blocks, the CommonMark and GFM standard. If the code element has a class like 'language-python' or 'lang-python', the language identifier is extracted and preserved in the opening fence for syntax highlighting. Code blocks converted from GitHub README pages or documentation sites retain their language tags in the output — so the syntax highlighting you had in HTML survives into Markdown.

How does this compare to Markdownify or h2m?

Markdownify and h2m are Node.js npm packages for programmatic HTML-to-Markdown conversion in a build pipeline. They're the right choice when you need to automate conversion across hundreds of files in a script. This browser tool covers the use case they don't: quick one-off conversions, content you can't share with a server, and situations where you don't want to set up a Node project at all. Conversion quality is similar — all three use DOM-based parsing rather than regex — but this tool adds a live preview, copy button, and character/word counts that make it more practical for content work.

Does this tool work on iPhone and Android?

Yes, the converter works fully on mobile browsers. Paste HTML from the clipboard, trigger conversion, and copy the Markdown result — all from a phone or tablet. The interface adapts to smaller screens with stacked panes. Tested on Safari for iOS 17 and Chrome for Android 14. One common mobile use case: grab an article's HTML from your browser's Share menu, convert it, and paste the Markdown directly into Obsidian or Notion on the same device, without needing a desktop at all. No sign-up, no app download, no limits.

What happens to HTML comments and script/style tags?

HTML comments (<!-- ... -->) are stripped from the output since Markdown has no comment syntax and comments are rarely part of the actual content. Script tags and their contents are also dropped — JavaScript is not meaningful in Markdown. Style tags and inline style attributes are removed too; CSS styling doesn't translate to Markdown, and the semantic meaning (bold, italic, heading) is preserved via the element type rather than the visual style. If a span is bold via CSS rather than a strong or b tag, that styling won't carry over — which is the correct behavior for a content format conversion.

Is there a file size or character limit?

No. There's no server involved, so no size limit beyond what your browser's memory can handle. In practice, the browser DOM parser can handle several megabytes of HTML without issues — far more than any real CMS page. If you're converting an extremely large HTML file (a complete book export, a very long scraped article), paste it in sections rather than all at once for the clearest output. The conversion itself takes milliseconds regardless of size because it runs directly in JavaScript in your browser tab.

Related tools

Tazama zana zote