How the converter works
Markdown is converted with marked, a widely used open-source parser that follows the CommonMark spec and supports GitHub-flavoured Markdown (GFM). The HTML it produces is then cleaned with DOMPurify before it is shown or copied. Both libraries are bundled with this page, so the converter works offline once loaded and conversion happens locally. Images in the preview can still make requests to their source servers.
The preview updates as you type. Switch to HTML source to see exactly what you will copy or download. Tick Full HTML document to wrap the output in a complete page with <!doctype html>, a UTF-8 charset, a viewport tag and a <title> taken from your first heading. Leave it off when you are pasting into a CMS, an email template or an existing page.
Markdown to HTML cheat sheet
Here is what common Markdown becomes, produced by the same parser the tool uses:
# Heading → <h1>Heading</h1>**bold** and _italic_ → <p><strong>bold</strong> and <em>italic</em></p>[link](https://example.com) → <p><a href="https://example.com">link</a></p>`inline code` → <p><code>inline code</code></p>~~deleted~~ → <p><del>deleted</del></p> (GFM)- [x] done → <ul><li><input checked="" disabled="" type="checkbox"> done</li></ul> (GFM)
Headings, paragraphs, lists, block quotes, fenced code blocks and images are supported. Strikethrough, tables, task lists and automatic links to bare URLs are GFM extensions.
GFM and line breaks: what the options change
GitHub-flavoured Markdown is on by default because it is what GitHub, GitLab and most documentation tools use. Turn it off to disable GFM extensions: the table | a | b | is then left as a plain paragraph of pipes and dashes instead of becoming a <table>.
Line breaks. In standard Markdown a single new line inside a paragraph is just a space, so “line one⏎line two” becomes <p>line one
line two</p>. To force a line break you end the line with two spaces or a backslash. GitHub comments (but not README files) treat every new line as a break; tick Line breaks to get the same result: <p>line one<br>line two</p>.
Why the HTML is sanitised
Markdown allows raw HTML, so a Markdown file can contain <script> tags, onerror attributes or javascript: links. If you paste output like that into a website, it runs in your visitors' browsers. This is a classic cross-site scripting (XSS) hole, and marked itself does not filter it.
This converter always runs the HTML through DOMPurify. Scripts, event handlers, unsafe links, iframes, styles, forms, SVG and MathML are removed. Normal formatting, links, images and tables are kept. Review links and image sources before publishing, and sanitise untrusted content on the server too.
Tables, column alignment and what GFM adds
Tables are a GFM extension, not part of core Markdown (GitHub Flavored Markdown Spec). A header row, a delimiter row of dashes and one or more body rows are enough. Colons in the delimiter row set alignment: :--- is left, :---: is centred and ---: is right. This input:
| Item | Qty | Price |
|:-----|:---:|------:|
| Pen | 2 | $1.50 |is converted by the parser on this page to:
<table>
<thead>
<tr>
<th align="left">Item</th>
<th align="center">Qty</th>
<th align="right">Price</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Pen</td>
<td align="center">2</td>
<td align="right">$1.50</td>
</tr>
</tbody></table>Each cell gets an align attribute, which browsers still honour, though you may prefer to restyle tables with CSS on your own site. With GFM switched off the same lines stay one paragraph: <p>| Item | Qty | Price | …. GFM also turns bare web addresses into links: <p>Visit <a href="https://example.com">https://example.com</a> today</p>, compared with <p>Visit https://example.com today</p> when GFM is off.
One quirk worth knowing: with GFM on, this parser treats single tildes as strikethrough too, so H~2~O becomes <p>H<del>2</del>O</p> rather than a subscript. Write H<sub>2</sub>O if you need chemistry notation.
Code blocks and syntax highlighting
There are two ways to write a code block. A fenced block uses three backticks (or three tildes) on the lines before and after the code, and can name a language after the opening fence:
```js
const x = 1;
```
→
<pre><code class="language-js">const x = 1;
</code></pre>An indented block uses four spaces at the start of every line and cannot carry a language name: indented code becomes <pre><code>indented code⏎</code></pre>. Both forms are defined in the CommonMark Spec 0.31.2.
The converter does not colour your code itself; it only adds the language-… class. Highlighting libraries such as Prism and highlight.js look for that class on your site and add the colours there. Inside code blocks and inline code, characters like < and & are escaped automatically, so HTML examples show as text instead of being rendered.
Lists, numbering and nesting
An ordered list keeps the number you start with. 3. Three⏎4. Four becomes <ol start="3"><li>Three</li><li>Four</li></ol>: the first number becomes the start attribute and later numbers are ignored, so you can number every item 1. and let the browser count.
To nest a list, indent the child items far enough to line up with the text of the parent item, which is three spaces after 1. . Indented correctly, 1. First⏎2. Second⏎ - nested becomes <ol><li>First</li><li>Second<ul><li>nested</li></ul></li></ol>. With only one space the dash is not inside the item, and the parser produces <ol><li>First</li><li>Second</li></ol><ul><li>nested</li></ul> instead. The CommonMark Spec 0.31.2 explains the exact indentation rules.
Lists can start straight after a paragraph line: Intro text⏎- item becomes <p>Intro text</p><ul><li>item</li></ul>. A blank line before the list makes your source easier to read, though, and some older Markdown tools need one.
Special characters, links and images
You do not need to write HTML entities yourself. Stray ampersands and less-than signs are escaped for you, so AT&T <3 5 < 6 becomes <p>AT&T <3 5 < 6</p>. A real tag, such as <b>, is passed through as HTML and then checked by the sanitiser.
Images use the link syntax with an exclamation mark in front. The text in square brackets becomes the alt attribute and an optional quoted title becomes title:  → <p><img src="logo.png" alt="Logo" title="Title"></p>. Alt text is what screen readers announce, and it is shown if the image fails to load (MDN: the img element).
Relative paths such as logo.png are left exactly as you wrote them. They will only work once the HTML sits on a site where that file exists, so check image and link paths after you paste the output into your CMS.
What this converter does not add
Footnotes. Footnotes are an extension some platforms support (GitHub does), but they are not part of CommonMark or the GFM spec, and the parser here does not support them. Footnote[^1] with a [^1]: Note line comes out as <p>Footnote<a href="Note">^1</a></p>, which is not what you want. Write footnotes as a numbered list at the end, or convert them by hand.
Heading IDs. ## Install steps becomes <h2>Install steps</h2> with no id attribute, so links to #install-steps will not jump anywhere. Some sites, GitHub included, add those anchors automatically when they render Markdown (GitHub Docs: basic writing and formatting syntax). If your page needs a table of contents, add the IDs in your CMS or template.
Styling. The output is plain semantic HTML with no CSS classes apart from code-block language classes. Fonts, colours and spacing come from the site you paste it into, which is usually what you want for a CMS or email builder.
Common Markdown to HTML mistakes
Expecting a new line to start a new line. A single new line inside a paragraph becomes a space. Use a blank line for a new paragraph, two trailing spaces or a trailing backslash for a line break (Line one\⏎line two → <p>Line one<br>line two</p>), or tick the Line breaks option.
Forgetting the blank line before a code fence or heading. Most parsers accept it, but it is easier to read and avoids surprises when the same file is rendered somewhere stricter.
Leaving GFM off by mistake. If a table or a task list appears as raw pipes or brackets, check that the GitHub-flavoured Markdown option is ticked.
Trusting HTML from someone else. Markdown that came from users, AI tools or unknown files can hide scripts in raw HTML. This page sanitises the output, but if your own site renders Markdown, sanitise on the server as well and follow the OWASP Cross Site Scripting Prevention Cheat Sheet.
Tips for clean HTML
Use one H1. Start the document with a single # heading and use ## for sections. The first heading also becomes the page title and the download file name.
Label code blocks. Write ```js rather than just ```. The output gets class="language-js", which syntax highlighters such as Prism and highlight.js pick up.
Add alt text.  becomes an image with a useful alt attribute for screen readers and search engines.
Escape special characters. Put a backslash before characters you want to show literally, for example \*not italic\*. If you need to find and fix a pattern across a long file first, try our regex tester. Converting config files rather than prose? Use the YAML to JSON converter.