Turn HTML into Markdown you can edit
HTML is what browsers read, Markdown is what people write. When a page, a blog export, a help article or an email template exists only as HTML, this converter gives you back plain Markdown that you can edit in any text editor, commit to a repository or paste into a wiki, a README or a note app. The structure is kept: headings stay headings, lists stay lists, tables become pipe tables and code blocks keep their language. What goes away is everything Markdown cannot express, such as styles, classes, scripts and layout.
The conversion runs on your device. Paste the source of a page or drop a saved .html file, and the result appears at once. The other direction, Markdown back to HTML, is the job of the Markdown to HTML converter, and a round trip through both is a quick way to check that nothing important was lost. To get only the words without any formatting, use HTML to text.
What becomes what
| HTML | Markdown |
|---|---|
| h1 to h6 | # Heading to ###### Heading |
| p, div, section | Paragraphs separated by a blank line |
| strong, b / em, i | **bold** / *italic* |
| del, s | ~~struck~~ |
| code | `inline code`, with a longer run of backticks when the code holds backticks |
| pre | Fenced block with the language from class="language-js", or four-space indentation |
| a | [text](url "title") |
| img |  |
| ul, ol, li | Lists with - or *, numbers from start, nesting by indentation, task lists from checkboxes |
| blockquote | Lines starting with > |
| table | Pipe table with a header row and alignment from align or text-align |
| hr / br | --- / two spaces at the end of the line |
| script, style, form, iframe, svg | Dropped |
The Markdown rules behind the output
The output follows the GitHub Flavored Markdown spec, which extends CommonMark. Headings use the ATX style: one to six # characters followed by a space (section 4.2). Code blocks are fenced with at least three backticks and an optional info string that names the language (section 4.5); when the code itself contains a run of three backticks, the fence is made longer so the block stays intact. A line break inside a paragraph is written as two trailing spaces, which the spec parses as a hard line break (section 6.12). Tables follow the tables extension (section 4.10): a header row, a delimiter row of hyphens with colons for alignment, and a pipe inside a cell escaped as \|. A table whose cells contain nested lists or tables cannot be written as a pipe table and falls back to its text.
Lists use - or * for bullets and 1. for numbers (section 5.2). Continuation lines of an item are indented to the width of the marker, so nested lists and multi-paragraph items belong to the right item. A list is written tight when its items are single paragraphs and loose, with blank lines between items, when an item holds several blocks.
Main content only
Pages copied from the web are mostly chrome: navigation, cookie notices, sidebars and footers. With Main content only on, the converter looks for a main element and uses only that; when there is none, it takes the first article; otherwise the whole body. In every case nav, header, footer and aside are skipped, wherever they appear. A note under the output tells you which part was used. Pages that put their content in plain div elements keep their menus, so switch the option off and delete those lines in the output instead.
Escaping and whitespace
Text that contains *, _, `, [ or < would change meaning in Markdown, so those characters are escaped with a backslash, as are a #, a > or a list marker at the start of a line. Inside code blocks nothing is escaped. Runs of spaces and line breaks in the HTML source collapse to one space, the way a browser shows them, except inside pre. HTML entities such as & and are decoded by the parser; a non-breaking space stays a non-breaking space in the output.
A worked example
The example button loads a short article with a heading, a paragraph with a link and bold text, a nested list, a code block in JavaScript and a two-column table, wrapped in a page with a nav and a footer. With Main content only on, the Markdown starts with the # heading of the article and ends with the table; the menu and the footer are gone. Switch the option off and the menu links appear as a list of Markdown links at the top.
Limits
- Markdown has no colors, fonts, alignment of text or column widths. Those styles are dropped. Underline, small text and marks become plain text.
- Merged table cells (colspan, rowspan) are not possible in a pipe table; the cell content is kept, the merge is not.
- Images keep their src as written, often a relative path or a data URL. Nothing is downloaded.
- Definition lists become the term on its own line and the definition indented under it; details and summary become plain paragraphs.
- Files up to 20 MB can be opened. Very large pages take a moment to parse.
How to use the HTML to Markdown converter
- 1Paste the HTML into the input box, or open or drop an .html file.
- 2Choose the bullet character and fenced or indented code. Turn on Main content only for pages copied from the web.
- 3Check the Markdown on the right, then copy it or download it as a .md file.
Sources
- GitHub Flavored Markdown Spec: ATX headings (4.2), fenced code blocks (4.5), tables extension (4.10), lists (5.2), hard line breaks (6.12)
- CommonMark Spec
Related guides
Frequently asked questions
How do I convert HTML to Markdown?
Paste the HTML into the input box or drop an .html file on it. The Markdown appears on the right as you type. Pick the bullet character and whether code blocks are fenced, then copy the result or download it as a .md file.
Which HTML elements are converted?
Headings h1 to h6, paragraphs, bold, italic, strikethrough, inline code, links with their title, images with their alt text, ordered and unordered lists with nesting, task lists, block quotes, pre and code blocks with the language from a class like language-js, tables as pipe tables, horizontal rules and line breaks. Scripts, styles, forms and embedded frames are dropped.
What does Main content only do?
Pages copied from the web carry menus, headers, footers and sidebars. With this option on, the converter uses the main element, or the first article element when there is no main, and skips nav, header, footer and aside everywhere. When the page has neither, the whole body is used without those parts.
Can I paste a whole web page?
Yes. Save the page as HTML or copy its source and paste it. Styles, scripts and the head are ignored. Images keep the address they had in the page, which may be relative, so check them before publishing the Markdown elsewhere.
Why are some characters escaped with a backslash?
Text that happens to contain *, _, [ or a leading # would otherwise be read as Markdown formatting. The converter escapes those characters so the text reads the same after conversion. Markdown renderers remove the backslashes again.
Which Markdown flavor is written?
CommonMark with the GitHub extensions for tables, strikethrough and task lists. ATX headings with #, fenced code blocks with three backticks and an info string, hard line breaks as two trailing spaces. The output works in GitHub, GitLab, static site generators and most note apps.
Is my HTML uploaded?
No. The page is parsed and converted by your browser. Files you open are read on your device, and nothing is sent to a server.