Markdown to HTML
Published Updated
Convert Markdown to HTML with the marked parser in GFM mode: tables, task lists, strikethrough and autolinks work, and a single line break stays inside its paragraph. Raw HTML is cleaned before you copy it: script-type tags are shown as text, and onerror-style attributes and javascript: links are removed.
What the converter produces
Output of the page's parser in Google Chrome 156, marked 18.0.7 with default options:
| Markdown | HTML |
|---|---|
~~gone~~ | <del>gone</del> |
- [x] done | A list item with a disabled, checked checkbox |
A pipe table with :-: | A table whose cells carry align="center" |
https://example.com/a_b | A link to the same address |
A fenced block marked js | <pre><code class="language-js"> |
| Two trailing spaces | A <br> inside the paragraph |
Markdown constructs and the HTML each becomes
Each input went through the page's own conversion (the size check, marked 18.0.7 and the cleaner) in Google Chrome 158, Firefox 155, Playwright's WebKit build (not the Safari app) and Node.js 22.23.1. The HTML text was the same in all four for all 41 constructs. The rows are measured outputs:
| Markdown | HTML written (↵ = line break) |
|---|---|
3. a↵4. b | <ol start="3">↵<li>a</li>↵<li>b</li>↵</ol>↵ |
1) a↵2) b | <ol>↵<li>a</li>↵<li>b</li>↵</ol>↵ |
| a | b | c |↵|:--|:-:|--:|↵| 1 | 2 | 3 | | <table>↵<thead>↵<tr>↵<th align="left">a</th>↵<th align="center">b</th>↵<th align="right">c</th>↵</tr>↵</thead>↵<tbody><tr>↵<td align="left">1</td>↵<td align="center">2</td>↵<td align="right">3</td>↵</tr>↵</tbody></table>↵ |
~gone~ | <p><del>gone</del></p>↵ |
me@example.com | <p><a href="mailto:me@example.com">me@example.com</a></p>↵ |
~~~python title=a↵x = 1↵~~~ | <pre><code class="language-python">x = 1↵</code></pre>↵ |
```↵x↵``` | <pre><code>x↵</code></pre>↵ |
a\↵b | <p>a<br>b</p>↵ |
<div>hi *not md*</div> | <div>hi *not md*</div> |
© & 5 < 6 and 7 > 3 & done | <p>© & 5 < 6 and 7 > 3 & done</p>↵ |
\*not italic\* \# not heading | <p>*not italic* # not heading</p>↵ |
**b** *i* _i_ __b__ snake_case_word 2*3*4 | <p><strong>b</strong> <em>i</em> <em>i</em> <strong>b</strong> snake_case_word 2<em>3</em>4</p>↵ |
a\r↵b\r↵\r↵c | <p>a↵b</p>↵<p>c</p>↵ |
CommonMark says the first word of a code fence's info string is typically used for the language and rendered in the class attribute, and that an ordered list takes its start number from its first item. The GitHub Flavored Markdown specification defines strikethrough as text in a matching pair of one or two tildes, and a www autolink as text that starts with www. followed by a valid domain.
Raw HTML is cleaned, not fully sanitized
marked's documentation states that it does not sanitize the output HTML and lists DOMPurify as the recommended filter. The GitHub Flavored Markdown specification defines a tagfilter that would turn a script tag into escaped text. This page applies it, together with a few more tags (object, embed, base, meta, svg and similar), and also removes on* attributes and links that start with javascript:, vbscript: or a data: address other than a picture. A notice appears when it removed something. This is a fixed list, not a full sanitizer such as DOMPurify.
The Preview tab is a further safeguard. It deletes remote image, frame and stylesheet references, and its iframe allows no scripts.
What the cleaner does to 65 HTML snippets
Each snippet was typed into the page, and the cleaned HTML was read back. Of 65 inputs, 49 were changed and 16 were not. The groups below cover every input once; the last two groups are the 16 that are not changed. The page counts opening and closing tags of an element separately, and the notice for the script snippet starts with Made safe: 2 unsafe items. The outputs were the same in all four runtimes.
| Group of inputs | Inputs | Items counted for each | One input | Its output (↵ = line break) |
|---|---|---|---|---|
| Both tags shown as text | 14 | 2 | <script>alert(1)</script> | <script>alert(1)</script> |
| One tag shown as text | 4 | 1 | <plaintext>x | <p><plaintext>x</p>↵ |
| An iframe with a srcdoc attribute | 1 | 4 | <iframe srcdoc="<script>1</script>"></iframe> | <iframe srcdoc="<script>1</script>"></iframe> |
| An svg with a link inside | 1 | 3 | <svg><a xlink:href="javascript:alert(1)">x</a></svg> | <p><svg><a>x</a></svg></p>↵ |
| Event-handler attribute dropped | 7 | 1 | <img src="x" onerror="alert(1)"> | <img src="x"> |
| Link or URL attribute dropped | 20 | 1 | [x](javascript:alert(1)) | <p><a>x</a></p>↵ |
| Style attribute dropped | 2 | 1 | <div style="background:url(javascript:alert(1))">x</div> | <div>x</div> |
| Kept as written | 13 | 0 | <img src="data:image/png;base64,iVBORw0KGgo="> | <img src="data:image/png;base64,iVBORw0KGgo="> |
| Not HTML after Markdown, so shown as text | 3 | 0 | <script/src=x> | <p><script/src=x></p>↵ |
The 13 kept inputs include http:, mailto:, tel:, sms: and ftp: links, relative and protocol-relative links, a picture whose src is a data:image/png address, a style attribute with color:red, and a remote img and link tag. Remote references stay in the copyable HTML and are removed only from the Preview.
In Preview, remote image, srcset, style and stylesheet references were deleted in all three browsers, a local image stayed, and the frame's sandbox attribute was allow-same-origin.
Size limits and speed
The size check refused 201 nested quote markers, a list item indented by 201 characters, 201 asterisks in a row and 201 underscores in a row. With 200 instead, the quote markers, the indentation and the asterisks passed. The same inputs behaved the same in all four runtimes, and the page showed the refusal message for the quote markers and for the asterisks. Time in milliseconds to convert and clean one generated document, median of 3 runs:
| Generated document | Node.js | Chrome 158 | Firefox 155 | WebKit build |
|---|---|---|---|---|
| 100 sections, 18,059 characters of Markdown, 38,560 of HTML | 13 | 9 | 22 | 11 |
| 1,000 sections, 184,559 characters of Markdown, 389,560 of HTML | 59 | 49 | 123 | 53 |
| 10,000 sections, 1,885,559 characters of Markdown, 3,935,560 of HTML | 762 | 346 | 1,048 | 493 |
Converting a document
Step 1
Paste Markdown or add a file
A .md or .txt file fills the editor. The HTML appears as you type, with nothing to press.
Step 2
Read the Source tab
This is the exact HTML that Copy HTML puts on the clipboard. Check it for tags you did not write.
Step 3
Use the Preview tab for layout only
It strips remote images and styles and runs in a sandbox. The copied source is cleaned of script-type tags, event-handler attributes and javascript: links, but remote images are kept in it.
Limits and defaults
marked's options page lists GFM as on and breaks as off, which is how this page runs.
- The result is a fragment of body markup. There is no html or head wrapper and no stylesheet, so supply your own CSS.
- More than 200 nested quotes or list levels is refused before parsing.
- More than 200 asterisks or underscores in a row is refused too.
- For Word output instead, Markdown to Word writes a DOCX, and HTML to Markdown goes the other way.
Markdown to HTML questions
Is the HTML safe to publish as it is?
Treat Markdown from someone else with care. The marked project warns that it does not sanitize output, so this page cleans it before you copy it: tags the GitHub specification filters (script, style, iframe and similar) are shown as text, onerror-style attributes and javascript: links are removed, and a notice says so. It is not a full sanitizer like DOMPurify, so run publishable output from untrusted sources through one.
Why did my single line break disappear?
In standard Markdown a lone line break is a space. Two spaces at the end of a line give a br tag. marked's breaks option, which would change that, is off in this page.
Do footnotes work?
No. The footnote reference text[^1] with a definition produced a link labelled ^1 pointing to the word note. Write footnotes as ordinary links or a numbered list.
Are there heading ids for anchor links?
No. A heading comes out as a plain h2 with no id attribute, so add ids yourself or link by other means.
Does it support math, emoji codes or smart quotes?
No. Dollar-sign math, :smile: and straight quotes are left exactly as typed, and quotes appear as entities.
Is my text uploaded?
No. Parsing happens in the page: your text is processed in your browser, and this page does not upload it.
Why does a script block count as two items in the notice?
The cleaner counts each tag it changes. A script element has an opening and a closing tag, and both are shown as text, so the notice for one script block says 2 unsafe items. A tag with a single bad attribute, such as an onerror image, counts 1.
Which link types are kept?
Links that start with http, https, mailto, tel, sms or ftp are kept, and so are relative and protocol-relative links. javascript: and vbscript: links lose their href, including versions written in capitals, with an entity, with a tab inside the word or with leading spaces. In the test, a data:image/png picture was kept, and a data:image/svg+xml picture and a data: link were not.
Does one tilde make strikethrough, and does www get a link?
Yes to both. ~gone~ gave a del element, www.example.com gave a link whose address is the same name with http added in front, and me@example.com gave a mailto link.
How long does a long document take?
A generated document of 10,000 sections (1,885,559 characters of Markdown) took a median of 762 ms in Node.js, 346 ms in Chrome 158, 1,048 ms in Firefox 155 and 493 ms in the WebKit build.