How to use the html to markdown converter
- Paste or type your HTML into the input area.
- The converter processes the markup instantly as you type.
- Copy the resulting Markdown from the output area below.
How the conversion works
The html to markdown conversion uses a single-pass linear tokenizer written by hand without DOM APIs. It reads each character exactly once, identifying tags, attributes, comments, doctypes and raw text elements like <script> and <style>. Void elements such as <br>, <hr> and <img> are handled without expecting closing tags.
For example, the input <h2>Title</h2> produces the token sequence: open tag h2, text node "Title", close tag h2. The converter maps this directly to ## Title. Unknown tags are ignored while their inner text is preserved, so custom elements do not break the output.
Supported HTML elements
The following table shows which HTML elements are converted and what Markdown syntax they produce:
| HTML element | Markdown output |
|---|---|
<h1> to <h6> | # to ###### |
<p> | Blank line separated text |
<strong>, <b> | **text** |
<em>, <i> | *text* |
<a href> | [text](url) |
<img> |  |
<ul><li> | - item |
<ol><li> | 1. item |
<code> | `code` |
<pre><code> | Fenced code block |
<blockquote> | > text |
<hr> | --- |
<br> | Line break (two spaces and newline) |
<table> | Pipe table syntax |
Entity decoding and escaping
HTML entities like &, <, >, " and numeric references such as ' or ' are decoded to their plain characters before Markdown formatting is applied. This ensures the output contains readable text rather than entity codes.
After conversion, characters that would trigger formatting in regular text are escaped with a backslash: asterisks, underscores, backticks, square brackets and the less-than sign anywhere, plus a leading hash, greater-than sign, list dash or plus, and "1." style numbering at the start of a line. Periods, hyphens and parentheses in ordinary sentences are left alone. If you need to go the other direction, the markdown to html tool reverses the process.
Handling tables and nested structures
HTML tables are converted to pipe-delimited Markdown tables. The first row becomes the header row, because Markdown tables require one, followed by a separator line of dashes; <thead>, <tbody> and <tfoot> rows are all read in order. Short rows are padded with empty cells and a pipe inside a cell is escaped. Each <td> or <th> becomes a cell. Inline formatting inside cells, such as bold or links, is preserved.
Nested lists are supported through indentation tracking. When an <ul> or <ol> appears inside a list item, the child items receive additional leading spaces. Blockquotes can also be nested, producing multiple > prefixes. Tables nested inside other tables are flattened to text. For simpler table needs, you might prefer the markdown table generator.
Performance limits and safety
To keep the page responsive on malformed input, the converter enforces two hard limits. Input larger than 2 MB is rejected immediately, and markup nested more than 300 elements deep returns an error message instead of a result. Unclosed tags are closed automatically, and unterminated comments, quotes and script blocks are handled without hanging.
Because everything runs locally in your browser, no HTML is transmitted over the network. You can safely convert documents containing sensitive content. If you only need plain text without any Markdown formatting, use the html to text tool instead.
Worked examples
| Example | Input | Result |
|---|---|---|
| Headings and text | HTML input: <h1>Title</h1><h2>Subtitle</h2><p>A paragraph with <strong>bold</strong> and <em>italic</em> text.</p> | # Title / ## Subtitle / A paragraph with **bold** and *italic* text. |
| Links and images | HTML input: <p>Visit <a href="https://example.com">Example</a>.</p><img src="photo.jpg" alt="A photo"> | Visit [Example](https://example.com). /  |
| Lists | HTML input: <ul><li>First item</li><li>Second item</li></ul><ol><li>Step one</li><li>Step two</li></ol> | - First item / - Second item / 1. Step one / 2. Step two |
| Code block | HTML input: <pre><code>function hello() { / return "world"; / }</code></pre> | ``` / function hello() { / return "world"; / } / ``` |
| Table | HTML input: <table><thead><tr><th>Name</th><th>Age</th></tr></thead><tbody><tr><td>Alice</td><td>30</td></tr></tbody></table> | | Name | Age | / | --- | --- | / | Alice | 30 | |
FAQ
What HTML elements does this html to markdown tool support?
It supports headings, paragraphs, strong, em, strikethrough, links, images, ordered and unordered lists (nested too), inline code, preformatted blocks, blockquotes, horizontal rules, line breaks and tables. Unknown tags are stripped but their text content is kept.
Are HTML entities decoded during conversion?
Yes. Named entities like & and numeric references like ' are decoded to their actual characters before the Markdown output is generated.
Is my HTML sent to a server?
No. The conversion happens entirely in your browser using JavaScript. Nothing is uploaded anywhere.
What happens with script and style tags?
The content inside script and style tags is treated as raw text and skipped. It does not appear in the Markdown output.
Can it handle very large HTML documents?
Input up to 2 MB is accepted. Markup nested more than 300 levels deep is rejected with an error message so the page cannot hang.
How are special Markdown characters in the HTML handled?
Asterisks, underscores, backticks, square brackets and less-than signs in plain text are escaped with a backslash, as are a leading hash, greater-than sign, list dash or plus and "1." numbering at the start of a line. Ordinary punctuation such as periods and hyphens is left alone.