HTML to Markdown

An HTML to Markdown converter turns HTML code into Markdown, the plain-text format that uses # for headings, - for bullets and pipes for tables. Paste HTML, or copy part of a web page and paste it as rich text, and you get clean Markdown for a README, a notes app or an AI prompt. Everything runs in your browser.

  • 100% free
  • No sign-up
  • Runs in your browser
  • Updated
Markdown options
Headings
Bullets
Code blocks
Links

Key takeaways

  • A product card with 3 features and a size table shrank from 671 to 203 characters, 70% smaller, with nothing meaningful lost.
  • The same card used 242 tokens as HTML and 78 as Markdown in the GPT-4o tokenizer, 68% fewer.
  • HTML tables become GitHub Flavored Markdown pipe tables; a table with no header row gets its first row promoted to the header.
  • Scripts, styles, forms and, by default, menus, sidebars, headers and footers are removed before converting.

How to use the HTML to Markdown

  1. 1Paste your HTML into the left box, or switch to Paste from a web page and paste content you copied from any site. A sample article is already loaded.
  2. 2Read the Markdown in the right box. It updates as you type.
  3. 3Pick your style under Markdown options: hash or underlined headings, the bullet marker, fenced or indented code, and inline or reference links.
  4. 4Untick Main content only if a part of the page is missing, and untick Keep images to drop image links.
  5. 5Press Copy or Download .md to save the result.

What is Markdown?

Markdown is a lightweight markup language: plain text with a few symbols that show structure. A line starting with # is a heading, ** around a word makes it bold, and a line starting with - is a bullet. John Gruber published it in 2004 so that text stays readable before it is ever rendered.

Today most tools follow CommonMark, a precise specification of the original syntax, or GitHub Flavored Markdown (GFM), which adds tables, strikethrough and task lists on top. This converter writes GFM, so the output works on GitHub, GitLab, Notion, Obsidian, Discord, Reddit and in most AI chat apps.

How do you convert HTML to Markdown?

Paste the HTML into the converter and copy the Markdown it returns; the tool maps each HTML element to its Markdown equivalent. An h1 becomes a line starting with #, a strong tag becomes **bold**, and each li inside a ul becomes a line starting with a dash.

Under the hood, the page parses your HTML with the browser's own DOMParser, so it reads messy or half-finished markup the same way a browser would. It then removes scripts, styles, inline SVG and form controls, and hands the clean tree to Turndown, an open-source HTML to Markdown library, with its GFM plugin for tables. Parsing never runs scripts or loads images, so pasting unknown HTML is safe. Class names, ids, inline styles and data attributes carry no meaning in Markdown, so they disappear, which is where most of the size saving comes from.

How do I convert a web page to Markdown?

Select the part of the page you want, copy it, choose Paste from a web page and paste. The browser puts the formatted HTML on the clipboard, so headings, links, lists and tables come across without you ever opening the page source.

To convert a whole page instead, open View Source (Ctrl+U, or Cmd+Option+U in Safari), copy everything and paste it into the HTML code box. With Main content only ticked, the converter keeps just the main element or the single article on the page, and drops nav, aside, site headers and footers. This tool does not fetch URLs for you; pasting keeps your browsing private and works on pages behind a login. If you are writing a site summary for AI crawlers, the llms.txt generator is the next step.

How are HTML tables converted to Markdown?

Each table becomes a pipe table: the header row, a line of dashes, then one line per row with cells separated by | characters. Column alignment set with align="center" or align="right" on a header cell is kept with colons in the dash line.

Markdown tables are simpler than HTML tables. They cannot merge cells, so a cell that spans two columns keeps its text in the first column and leaves the next one empty. A cell can hold only one line, so a list or several paragraphs inside a cell are joined with spaces, and a | inside a cell is escaped as \| so it does not split the row. Nested tables come out flattened into one cell and need a manual fix. If your table is really data, you may prefer a structured format: the JSON to TOON converter packs rows of records into very few tokens.

Why convert HTML to Markdown for ChatGPT, Claude or Gemini?

Markdown gives a language model the structure of a page in far fewer tokens than HTML. Tags, attributes and class names can make up more than half of a page's source, and every one of them costs tokens without adding meaning, while the # and - marks that remain tell the model exactly which line is a heading and which is a list item.

That matters when you paste documentation, a policy page or a product listing into a chat, or feed pages into a retrieval pipeline. Fewer tokens leave more room in the context window and cut API costs. To measure the difference on your own page, paste both versions into the AI token counter. For documents that start as PDFs, the PDF to Markdown converter does the same job.

Worked example

Converting a product card to Markdown

Take a product card from an online shop: a heading, a price with the old price struck through, three features in a bullet list and a size table with a header and two rows. Every element carries a class name, as it would on a real site. The HTML is 671 characters long.

The converter returns 12 lines of Markdown: ## Trail Running Shoes / **Price:** 89.00 USD ~~110.00 USD~~ / - Weight: 280 g / - Heel drop: 6 mm / - Waterproof: yes / | EU size | US size | In stock | / | --- | --- | --- | / | 42 | 8.5 | Yes | / | 43 | 9.5 | No |. (A slash marks a new line; blank lines are left out.) That is 203 characters, 70% shorter, and every price, feature and size is still there.

For AI use the token count matters more than characters. With the GPT-4o tokenizer (o200k_base) the HTML is 242 tokens and the Markdown is 78, a saving of 164 tokens or 68%. Repeat that over a catalog of 1,000 products and you save about 164,000 input tokens.

HTML to Markdown cheat sheet

What each common HTML element becomes with the default options. The Markdown column is generated by the converter itself.

ElementHTMLMarkdown
Heading 1 to 6<h2>Pricing</h2>## Pricing
Bold and italic<strong>bold</strong> <em>italic</em>**bold** *italic*
Strikethrough<del>old</del>~~old~~
Bullet list<ul><li>One</li><li>Two</li></ul>- One / - Two
Numbered list<ol start="3"><li>Three</li><li>Four</li></ol>3. Three / 4. Four
Inline code<code>npm ci</code>`npm ci`
Quote<blockquote>Note</blockquote>> Note
Line breakLine 1<br>Line 2Line 1, two spaces, new line, Line 2
Horizontal rule<hr>---
Link<a href="https://example.com">Docs</a>Link text in square brackets, then the URL in round brackets
Image<img src="logo.png" alt="Logo">An exclamation mark, the alt text in square brackets, then the image URL in round brackets
Table<table> with <th> header cellsHeader row, a line of --- cells, then one row per line, cells split by |

A slash ( / ) marks a new line. Choose Underline for headings to get Setext style (a line of = or - under the text) for levels 1 and 2.

Frequently asked questions

Is this HTML to Markdown converter free and private?

Yes, it is free with no sign-up and no limit beyond 2 million characters per paste. The HTML is parsed and converted by JavaScript in your browser tab, so nothing you paste is uploaded, logged or stored on a server. Closing or refreshing the page clears it, which makes it safe for internal docs and client pages.

Which Markdown flavor does the converter output?

It outputs GitHub Flavored Markdown, which is CommonMark plus tables, strikethrough with two tildes and task-list checkboxes. Everything except tables and strikethrough is plain CommonMark, so it also renders correctly in Markdown viewers that support only the core syntax. Choose the heading, bullet, code block and link style that matches your project's style guide.

Can I convert an HTML table to a Markdown table?

Yes. Every simple HTML table becomes a GFM pipe table, with alignment kept from align attributes on the header cells. If the table has no th cells, the first row is used as the header, because Markdown tables need one. Merged cells and nested tables have no Markdown form, so check those tables by eye.

Does the converter keep links and images?

Yes. Links keep their text and address, either inline or as numbered references listed at the end if you pick Reference. Images become Markdown image links with their alt text, unless you untick Keep images. Relative addresses such as /about stay relative, so add the site's domain if you use the Markdown somewhere else.

Why is part of my page missing from the Markdown?

Most likely Main content only removed it. With that option on, the converter keeps only the main element, or the single article, and drops navigation, sidebars, site headers and footers. Untick it to convert everything. Text drawn inside canvas or SVG, and text loaded by JavaScript after the page opened, is not in pasted source code either.

How do I convert Markdown back to HTML?

Most Markdown editors and static site generators turn Markdown into HTML when they render it, and GitHub does the same for any .md file. For a Word document instead of HTML, paste the Markdown into our ChatGPT to Word converter, which builds real headings, lists and tables in a .docx file.

Sources

Last reviewed by the ToolsFiesta team.

Related tools