Markdown
HTML

How to convert Markdown to HTML

  1. Paste your Markdown text into the input field — a .md file, a GitHub README fragment, or any Markdown snippet.
  2. Click "Convert" — the HTML output appears instantly in the right panel.
  3. Switch to "HTML → Markdown" using the toggle above the fields if you need the reverse direction.
  4. Click "Copy" to copy the HTML to clipboard, or "Download .html" to save the file locally.
  5. 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.

How marked.js converts Markdown to HTML
// 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 syntaxHTML outputNotes
# 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
![alt](src)<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.
GFM pipe table syntax and its HTML output
// 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.

How to sanitize the output before inserting into the DOM
// 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.

Frequently Asked Questions

Does the converter support GitHub Flavored Markdown (GFM)?
Yes. GFM extensions are enabled by default: fenced code blocks, pipe tables, ~~strikethrough~~, and automatic URL hyperlinking. This matches the rendering used by GitHub, GitLab, Bitbucket, and most modern static site generators.
How are fenced code blocks converted to HTML?
Fenced code blocks (``` language) are converted to <pre><code class="language-xxx">code</code></pre>. The language identifier is preserved as a class attribute for use with syntax highlighting libraries like Prism.js or highlight.js. Indented code blocks (4-space indent) produce the same <pre><code> output without a language class.
Does the output include a full HTML document or just a fragment?
Fragment only — just the HTML elements for the content, without a <html>, <head>, or <body> wrapper. This is intentional: in most use cases you embed the converted HTML inside an existing page template. If you need a full document, wrap the output in your own boilerplate.
Can I use raw HTML tags inside my Markdown?
Yes — marked.js passes raw HTML through to the output unchanged. You can embed <div class="alert">, <iframe>, or any HTML tag directly in your Markdown source. The HTML will appear verbatim in the output. This is standard CommonMark behaviour supported by most Markdown parsers.
How are images handled in the conversion?
![alt text](src url) is converted to <img src="src url" alt="alt text">. The output does not add width, height, loading="lazy", or any other attributes. If you need responsive images or lazy loading, add those attributes manually after conversion.
Is the HTML output safe to insert directly into a web page?
If you authored the Markdown yourself, yes. If the Markdown comes from user input or third-party sources, sanitize the HTML output first using a library like DOMPurify. Markdown allows raw HTML pass-through, which means a crafted Markdown file can produce XSS-vulnerable output.
What happens to front matter (YAML or TOML blocks at the top)?
Front matter is not stripped automatically. The --- delimiters may be interpreted as an <hr> tag or a heading underline depending on their context. If your Markdown file contains front matter, remove it before converting — otherwise the meta block will appear as content in the HTML output.
What happens to empty lines between paragraphs?
A single blank line between paragraphs creates a <p> tag boundary — the standard Markdown paragraph rule. Multiple blank lines are treated as a single blank line; they do not produce extra <p> tags or <br> elements. Inside code blocks, empty lines are preserved exactly.
What encoding is used for the downloaded HTML file?
The downloaded file is encoded as UTF-8. All Unicode characters — accented letters, CJK characters, mathematical symbols, emoji — are preserved correctly.
Can I convert a GitHub README.md to HTML with this tool?
Yes. Paste the README content and click Convert. The output will closely match what GitHub renders, since this converter uses the same GFM extensions (tables, code fences, strikethrough). Styling will differ — GitHub applies its own CSS on top of the HTML.
Is there a file size limit for the conversion?
No server-side limit exists because the conversion runs entirely in your browser. Practical limits are set by your browser's memory and JavaScript engine. Files up to several megabytes convert without issue on modern devices.
Can I round-trip: Markdown → HTML → Markdown?
Yes — use this tool first, then use the HTML to Markdown converter. However, the round-trip is not lossless. Heading underline style may change, list marker characters may change, and any raw HTML you embedded in Markdown will be converted to its Markdown equivalent (if one exists) or stripped.