Markdown to HTML Converter
Paste Markdown — get valid HTML output instantly. Nothing leaves your browser.
How to convert Markdown to HTML
- Paste your Markdown text into the input field — a .md file, a GitHub README fragment, or any Markdown snippet.
- Click "Convert" — the HTML output appears instantly in the right panel.
- Switch to "HTML → Markdown" using the toggle above the fields if you need the reverse direction.
- Click "Copy" to copy the HTML to clipboard, or "Download .html" to save the file locally.
- Embed the output HTML in your web page, CMS template, or pass it to a rendering pipeline.
How the Markdown to HTML converter works
The converter runs entirely in your browser using marked.js, a fast, spec-compliant Markdown parser. When you click Convert, the input Markdown string is tokenised by the lexer, then each token — heading, paragraph, code fence, list, table, link — is rendered to its HTML equivalent by the renderer. The output is valid, semantic HTML that can be embedded directly in any web page. No data leaves your browser — the conversion is purely local.
marked.js implements the CommonMark specification with GitHub Flavored Markdown (GFM) extensions enabled by default. This means fenced code blocks, pipe tables, and ~~strikethrough~~ are all supported in addition to standard Markdown syntax.
// marked.js runs this logic in your browser — no server involved:
import { marked } from 'marked'
marked.setOptions({
gfm: true, // GitHub Flavored Markdown: tables, ~~strikethrough~~
breaks: false, // false = standard paragraph separation
})
const md = '# Hello\n\nA **bold** and *italic* sentence.'
const html = marked.parse(md)
// Output:
// <h1>Hello</h1>
// <p>A <strong>bold</strong> and <em>italic</em> sentence.</p>Markdown syntax and the HTML it generates
Each Markdown syntax element maps to a specific HTML element. The table below shows the full set of supported syntax and the corresponding HTML output. Knowing this mapping helps you predict the result and write Markdown that produces the exact HTML structure you need.
| Markdown syntax | HTML output | Notes |
|---|---|---|
| # Heading | <h1>Heading</h1> | h1–h6 for # through ###### |
| **bold** | <strong>bold</strong> | Double asterisk or double underscore |
| *italic* | <em>italic</em> | Single asterisk or single underscore |
| [text](url) | <a href="url">text</a> | Inline link |
|  | <img src="src" alt="alt"> | Inline image |
| - item | <ul><li>item</li></ul> | Unordered list (also + and *) |
| 1. item | <ol><li>item</li></ol> | Ordered list |
| `code` | <code>code</code> | Inline code |
| ```\ncode\n``` | <pre><code>code</code></pre> | Fenced code block |
| > quote | <blockquote>quote</blockquote> | Block quote |
| --- | <hr> | Horizontal rule (also *** and ___) |
| ~~text~~ | <del>text</del> | Strikethrough (GFM) |
| | a | b |\n|---|---| | <table>…</table> | Pipe table (GFM) |
When to use Markdown as your content source
Markdown as source works well when:
- Writers edit the content — Markdown is faster to type and easier to read than raw HTML for non-developers.
- Git version control is used — Markdown diffs cleanly; HTML tag noise obscures actual content changes in pull requests.
- Static site generators are involved — Hugo, Astro, Jekyll, Eleventy, and Gatsby all accept Markdown as first-class input.
- Documentation platforms — Docusaurus, MkDocs, GitBook, and VitePress are all Markdown-native.
- Multi-platform publishing — the same Markdown source can render to HTML, PDF, and EPUB without editing.
Write HTML directly when:
- Layout control is needed — grids, absolute positioning, responsive breakpoints have no Markdown equivalent.
- Custom attributes are required — data-*, aria-*, CSS classes, and id values must be in raw HTML.
- Interactive elements are embedded — forms, iframes, custom web components, JavaScript event handlers.
- Email templates — email clients render HTML; most do not support Markdown or its converted output reliably.
- Complex tables — merged cells (colspan, rowspan) are not possible in Markdown pipe table syntax.
GitHub Flavored Markdown extensions supported
Beyond standard CommonMark, this converter enables the GitHub Flavored Markdown (GFM) extensions used by GitHub, GitLab, and most modern static site generators. These extensions add commonly needed features that standard Markdown omits:
- Fenced code blocks — triple backtick (```) delimiters with an optional language identifier. The language is preserved as a CSS class on the <code> element for syntax highlighting libraries.
- Pipe tables — | col1 | col2 | syntax produces a full <table> with <thead> and <tbody> elements.
- Strikethrough — ~~text~~ produces <del>text</del>.
- Automatic URL linking — bare https:// URLs in text are converted to clickable <a> tags.
- Hard line breaks — two trailing spaces followed by a newline produce a <br> tag.
// Markdown input:
| Name | Language | Stars |
|--------|----------|-------|
| React | JS | 230k |
| Vue | JS | 210k |
| Svelte | JS | 80k |
// HTML output:
<table>
<thead>
<tr><th>Name</th><th>Language</th><th>Stars</th></tr>
</thead>
<tbody>
<tr><td>React</td><td>JS</td><td>230k</td></tr>
<tr><td>Vue</td><td>JS</td><td>210k</td></tr>
<tr><td>Svelte</td><td>JS</td><td>80k</td></tr>
</tbody>
</table>Security: raw HTML output and XSS
The converter outputs raw HTML without sanitization. This is intentional — sanitizing would silently strip valid HTML that you might deliberately embed inside Markdown using pass-through syntax. If you plan to insert the output into a page that displays content from untrusted users, always sanitize the HTML with a library like DOMPurify before inserting it into the DOM. For content you authored yourself, the raw output is safe to use directly.
// If using the converted HTML with user-supplied content:
import DOMPurify from 'dompurify'
const rawHtml = marked.parse(userMarkdown)
const safeHtml = DOMPurify.sanitize(rawHtml)
document.getElementById('content').innerHTML = safeHtml
// DOMPurify removes <script>, on* event handlers, and
// dangerous href/src values while keeping all valid markup.