How to convert Markdown to HTML
- Paste or type Markdown into the Markdown box. The page opens with a short example; clear it to start your own.
- Read the code in HTML Output. It updates as you type.
- Keep Sanitize ticked unless you wrote the Markdown yourself. It removes scripts, event handler attributes, inline styles, forms and unsafe links.
- Choose CSS Classes: None for plain HTML, Tailwind prose to wrap the output in an article with the prose classes, or Bootstrap to wrap it in a container and add table and blockquote classes.
- Tick Treat single newlines as line breaks if every newline should start a new line.
- Press Copy HTML for the code, or Download .html for a complete page. The Bootstrap choice adds a link to Bootstrap 5.3.8 CSS in the download.
How the conversion works
The page uses marked 18.1.0, a parser for CommonMark plus the GitHub Flavored Markdown extensions: tables, task lists, strikethrough and autolinks. Sanitizing uses DOMPurify 3.4.16 with its HTML profile, which parses the generated HTML and removes anything that can run script, such as script tags, onerror-style attributes, iframes and javascript: links. This page also strips form and style elements and inline style attributes. Both libraries load from jsDelivr at an exact version with an integrity hash, so a changed file is rejected. Your Markdown is converted in your browser and is not uploaded.
Worked example with the default Markdown
The default Markdown is a heading, a sentence with bold text and a link, and a two-item list. With Sanitize ticked and CSS Classes set to None, HTML Output shows these 6 lines (149 characters of Markdown became 210 characters of HTML):
<h1>Weekly update</h1> <p>Shipped the <strong>new pricing page</strong> and fixed <a href="https://example.com/bugs">three bugs</a>.</p> <ul> <li>Write the release notes</li> <li>Send the newsletter</li> </ul>
The # became an h1, the double asterisks became strong, the bracket and parenthesis link became an a element, and each dash item became an li inside a ul.
Limits and edge cases
- The output is an HTML fragment. Download .html wraps it in a full page with a title taken from your first heading.
- Markdown inside a raw HTML block is left as written, as CommonMark specifies.
- Code fences get a class such as language-js but no colouring. Add a highlighter like Prism or highlight.js on your site.
- The colours in HTML Output are only for reading. Copy HTML copies plain text.
To see the rendered result while you write, use the Markdown Preview editor. For a PDF use Markdown to PDF, and to tidy the generated code try the HTML Beautifier.
Frequently asked questions
How do I convert Markdown to HTML?
Paste your Markdown into the Markdown box and the HTML appears in the HTML Output panel straight away. Press Copy HTML to paste it into a CMS or email template, or Download .html to save a complete page. Nothing needs to be installed.
Is the HTML output safe to paste into my site?
Only with Sanitize ticked, which runs the output through DOMPurify to remove scripts, event handler attributes, forms and javascript: links. Markdown allows raw HTML, so Markdown you did not write can carry scripts. Review sanitized output before you publish it.
Does it support tables and task lists?
Yes. The converter follows GitHub Flavored Markdown, so pipe tables, task lists such as - [x] Done, strikethrough with double tildes, autolinked URLs and fenced code blocks all convert. Task list items become disabled checkbox inputs.
Why do single line breaks not show up in the HTML?
In standard Markdown a single newline inside a paragraph is only a space. A blank line starts a new paragraph, and two spaces at the end of a line force a line break. Tick Treat single newlines as line breaks to turn every newline into a line break tag, as GitHub comments do.
Sources: CommonMark specification; GitHub Flavored Markdown specification; marked documentation; DOMPurify project.