Skip to main content
Text Tools

Markdown ↔ HTML Converter

Convert Markdown to HTML and back. Live two-pane preview. All processing runs in your browser.

No upload — your files never leave your device

  • 100% private
  • Runs in your browser
  • Works offline
  • No sign-up

About Markdown ↔ HTML Converter

Markdown ↔ HTML Converter does the two-way conversion in your browser with a live side-by-side preview. Paste markdown on the left to see the rendered HTML on the right, or paste HTML on the left to get clean markdown back. Useful when migrating a blog from one CMS to another, dropping markdown into a CMS that only takes HTML, or pulling rich-text from an email or a Notion export back into editable markdown. Output uses GitHub-flavoured markdown conventions on the markdown side and semantic, class-free HTML on the HTML side.

  • No uploads
  • Browser-only
  • Works offline
  • 100% free

How it works

  1. 1

    Pick a direction

    Use the toggle at the top to switch between Markdown → HTML and HTML → Markdown. The two panes swap roles instantly.

  2. 2

    Paste your source

    Drop markdown or HTML into the editable left pane. The right pane shows the converted output live as you type or paste.

  3. 3

    Copy or download

    Copy the conversion result with a single button, or download as a .md or .html file. The HTML output is sanitised against XSS, so it's safe to paste into a CMS.

When to convert Markdown to HTML (and back)

Markdown and HTML solve different problems. Markdown is for writing — terse, readable, fast to type. HTML is for rendering — what browsers, email templates and CMS rich-text fields actually understand. You convert Markdown to HTML when you need to paste formatted content somewhere that won't render Markdown itself: a website template, a newsletter tool, a help-desk reply box, a database field that stores HTML. You convert the other direction when you've inherited HTML and want clean, editable, version-control-friendly source.

The conversion is well-defined for the common constructs. Headings, paragraphs, bold and italic, links, images, lists, blockquotes, inline code and fenced code blocks all map cleanly between the two. The interesting questions are at the edges: what survives the round trip, and whether the HTML you're handling is safe.

What survives the round trip, and what doesn't

ElementMD to HTMLHTML to MDNotes
Headings, bold, italic, links, listsCleanCleanThe core mapping is lossless
TablesClean (GFM)Clean if simpleMerged/spanned cells have no Markdown equivalent
Inline / fenced codeCleanCleanLanguage hints may be dropped going back to MD
Inline styles, classes, IDsPassed through as raw HTMLDroppedMarkdown has no syntax for CSS or attributes
div, span, layout wrappersPassed throughUsually droppedMarkdown can't express arbitrary structure

Rule of thumb: anything Markdown can't express (styling, attributes, complex structure) is lost when converting HTML back to Markdown.

Sanitization and the safety of HTML

HTML is executable in a way Markdown is not. A Markdown document can embed raw HTML, including script tags, event handlers like onclick, and javascript: URLs — and if you render that HTML on a page without filtering it, you've created a cross-site scripting (XSS) hole. This is one of the OWASP Top 10 risk categories; the practical defense is documented in the OWASP XSS Prevention Cheat Sheet at owasp.org. Never trust HTML produced from Markdown you didn't write.

The correct pattern is convert, then sanitize: generate the HTML, then run it through an allowlist sanitizer (DOMPurify is the standard client-side choice) that strips scripts, dangerous attributes and unknown tags before it ever reaches the DOM. Converting is not sanitizing — a converter faithfully reproduces whatever was in the source, malicious or not. If the Markdown came from an untrusted user, sanitization is mandatory, not optional.

Common mistakes

  • Assuming the conversion is reversible. MD to HTML to MD rarely returns byte-identical source: whitespace, optional syntax and attributes normalize or vanish.
  • Pasting converted HTML into a WYSIWYG editor that re-wraps it in its own markup, producing nested, redundant tags. Paste as plain text or use the editor's HTML source mode.
  • Forgetting that GFM tables and task lists won't survive into a strict-CommonMark target. Confirm what the destination supports — see Markdown Preview for the CommonMark-vs-GFM differences.
  • Treating conversion output as trusted. If you'll display it, sanitize it; if you'll only store the source, Text Clean helps strip invisible characters that sneak in from rich-source pastes.

Frequently asked questions about Markdown ↔ HTML Converter

  • Why convert HTML back to markdown — what's the use case?

    Common one: you copy a styled paragraph from a Google Doc, Notion, or an email and you want it back as plain markdown for a README, an issue, or a static-site post. Another: migrating content from a WYSIWYG CMS (Wordpress, Ghost) into a markdown-based one (Hugo, Astro, Docusaurus) where you need bulk HTML→md conversion to preserve headings, lists, and links.

  • What about embedded styles or inline CSS in the HTML input?

    Markdown has no equivalent for arbitrary CSS, so styles like font-color or text-align are dropped during HTML → Markdown conversion. Structural elements (headings, lists, tables, links, images, code) round-trip cleanly. If you need to keep styling, the HTML → Markdown conversion isn't the right tool — keep the content as HTML.

  • How is this different from the Markdown Preview tool?

    Markdown Preview is one-way (md → rendered HTML view) and optimised for reading. This converter is two-way, exposes the raw HTML output for copying, and supports HTML → md going the other direction. Use Preview to read; use the Converter when you actually need to move content between formats.

Privacy, offline use, browser support, and pricing questions are answered on the site-wide FAQ.

See all Text tools