Skip to main content

Markdown to HTML

Convert Markdown to HTML with live preview.

Reviewed by · Last reviewed

How to Use the Markdown to HTML Converter

  1. Paste or type Markdown into the input pane. A README, a blog post draft, a Notion export, a GitHub wiki page, or any CommonMark-compatible text works.
  2. Toggle between tabs: HTML Code shows the raw generated markup; Preview shows how that markup renders in the browser.
  3. Click Copy HTML to paste the generated markup into a CMS, an email template builder, or an HTML file directly.
  4. Iterate live - typing in the input pane updates both views on every keystroke so you can see exactly how your Markdown maps to HTML.

Under the Hood

The converter implements the commonly used core of CommonMark: headings, emphasis, lists, links, images, code blocks, blockquotes, and horizontal rules. It works line by line for block-level constructs (headings, list items, fences) and then passes the collected paragraph content through an inline parser that handles emphasis, backtick spans, links, and images. That two-pass architecture matches how every serious Markdown implementation (cmark, markdown-it, pulldown-cmark) structures its work.

For safety the converter escapes user HTML at the point of entry when it could form a <script> or other dangerous tag, rather than passing raw HTML through wholesale. The result is the same output you would get from a reasonable default CommonMark renderer: semantic HTML5 elements, no inline styles, no class names. Add styling by wrapping the output inside an existing design system - the Markdown-to-HTML step is intentionally style-agnostic. Recent patches also guard against malformed input like unbalanced image URLs that previously caused infinite loops.

Good Uses

  • Writing an email in Markdown and converting to HTML for a Mailchimp or Brevo campaign that accepts custom HTML.
  • Drafting a page in Markdown inside your editor and pasting HTML into a CMS that does not support Markdown directly.
  • Producing a preview of a README change before pushing the commit, especially for GitHub-flavored features.
  • Generating the HTML portion of a content file for a static site generator that does its own Markdown rendering but you want to compare output.
  • Creating the inner HTML for a rich-text editor that accepts HTML as its serialisation format.
  • Teaching Markdown syntax by letting students see source-to-HTML mapping in real time.

Watch Out For These

  • GFM extensions. Task lists - [ ], tables with pipe syntax, and strikethrough with ~~text~~ are GitHub Flavored Markdown extensions. The core converter supports the most common ones; obscure extensions may not render.
  • HTML inside Markdown. CommonMark allows raw HTML blocks. Those pass through the converter, which means they render in the preview. That is powerful but introduces XSS risk if the Markdown came from an untrusted source; keep the output sanitised if you accept input from users.
  • Setext vs ATX headings. Underlined headings (=== under the text) are supported alongside #-style. Some older Markdown tools produce setext, so both shapes convert identically.
  • Reference-style links. Links of the form [text][ref] followed by [ref]: url are recognised; the reference definition does not render as text.
  • Hard line breaks. Two trailing spaces at the end of a line or a backslash produce a <br> per CommonMark. Single line breaks inside paragraphs are joined, which sometimes surprises people coming from platforms where every newline becomes a break.

CommonMark Specification

CommonMark is a standardised dialect of Markdown developed by John MacFarlane and others, first released in 2014 and currently at version 0.31.2. The spec at spec.commonmark.org includes a reference implementation (cmark) and a comprehensive test suite of over 600 cases. Before CommonMark, Markdown had dozens of incompatible implementations; the same input rendered differently on Reddit, Stack Overflow, GitHub, and Daring Fireball. CommonMark reduces that ambiguity. GitHub Flavored Markdown is specified as CommonMark plus a handful of extensions: tables, task lists, strikethrough, autolinks, and disallowed raw HTML. GFM is what you see on GitHub and is the closest thing to a "modern default" Markdown flavor.

Alternatives

markdown-it is the most popular JavaScript Markdown library and is what VS Code uses internally for its preview. remark is a full AST-based toolchain that lets you transform Markdown before rendering. pandoc, written in Haskell, is the Swiss Army knife: Markdown to HTML, to DOCX, to PDF, to LaTeX, all from one binary. For static site generators, Hugo ships with Goldmark, Astro uses remark internally, and Next.js supports MDX which combines Markdown with JSX. Reach for a build-step library when you need pipeline integration, custom plugins, or syntax highlighting. This in-browser tool is for the one-off case where you just need HTML from a Markdown snippet without installing anything.

Frequently Asked Questions

Does the converter support all of CommonMark?

It supports the commonly used parts: headings, paragraphs, emphasis, links, images, ordered and unordered lists, fenced code blocks, inline code, blockquotes, horizontal rules, and reference-style links. The deep corners of the spec - HTML blocks inside list items, link reference definitions nested in blockquotes, edge-case emphasis parsing - follow the spec where commonly encountered but may not pass the full 600+ item CommonMark test suite. For mission-critical use, render with <code>markdown-it</code> or <code>remark</code> in strict mode.

Is GitHub Flavored Markdown supported?

The common subset: fenced code blocks with language hints, autolinking plain URLs, and strikethrough with <code>~~text~~</code>. Tables with pipe syntax and task lists work in most cases but have quirks around cell alignment syntax. For perfect GFM output, use <code>remark-gfm</code> in a Node script; for quick previews, this tool is usually close enough that you can spot-check the result in GitHub's preview pane before committing.

Does my Markdown get uploaded?

No. The converter runs as a Preact component inside your browser tab and produces HTML through a local function call. There is no fetch request, no websocket, no localStorage persistence. Markdown often contains draft content you would not want indexed by a third party, so the local-only guarantee matters; you can verify it with DevTools Network showing zero requests when you type in the input.

How does the preview tab work?

The preview uses the same generated HTML that the Code tab displays, rendered inside a sandboxed prose container on the page. The container applies a minimal reading-friendly stylesheet (readable font, comfortable line-height, constrained width) so you can judge structure and hierarchy. Final appearance depends on the CSS of the page where you paste the HTML; the preview is a neutral baseline, not a specific target design.

Can raw HTML inside my Markdown render in the preview?

Yes. CommonMark explicitly permits raw HTML blocks and inline HTML, and the preview honours them. Recent hardening (commit 540fe3d) blocks <code>&lt;script&gt;</code> tags and other high-risk markup to prevent XSS, but most presentational HTML (<code>&lt;div class="callout"&gt;</code>, <code>&lt;table&gt;</code>, <code>&lt;picture&gt;</code>) passes through. If you are converting Markdown from an untrusted source, sanitise the output before publishing.

Why do some paragraphs collapse when I paste wrapped text?

CommonMark joins consecutive lines inside a paragraph, treating the line breaks as simple whitespace. This is deliberate: it matches how prose is typeset in typography, where a single newline is not a break. To force a line break inside a paragraph, end the line with two spaces or a backslash. To split into separate paragraphs, use a blank line between them.

What about fenced code blocks with nested backticks?

A fence that opens with three backticks can contain single or double backticks inside without closing prematurely. If you need to include three or more backticks in code, open the fence with four or more of the matching character and close with the same count. The converter preserves the opening fence length for the close, which matches CommonMark's rules.

Are links opened in a new tab?

No. CommonMark produces plain <code>&lt;a href="..."&gt;</code> without <code>target="_blank"</code> or <code>rel</code> attributes, because those are presentational choices that belong in your rendering environment's CSS or JavaScript rather than in the Markdown source. If you want new-tab behaviour, post-process the HTML or use a renderer with a plugin that adds those attributes based on URL.

How are images sized?

They are not. Markdown <code>![alt](src)</code> emits <code>&lt;img&gt;</code> with <code>src</code> and <code>alt</code> only; no width or height is added. Width must be set by CSS in your target rendering context, or by the original image's intrinsic dimensions loaded over the network. GFM allows dimensions with a query parameter in some renderers; this converter does not implement that extension.

Can I use this for email HTML?

The raw Markdown-to-HTML output works for email but most email clients need inline styles because external and even <code>&lt;style&gt;</code> blocks are often stripped. Run the generated HTML through an inlining tool like Juice or Premailer, or use a dedicated email-focused Markdown tool like MJML. For plain transactional emails with simple formatting the unstyled output of this tool is enough.

More Text Tools