Skip to main content

← Back to blog

How to Convert Markdown to HTML (and Back Again)

Markdown lets you write formatted text with plain characters — # for a heading, - for a bullet, **bold** for emphasis. HTML is the tagged markup browsers actually render. Converting Markdown to HTML turns your shorthand into <h1>, <ul> and <strong>; going the other way turns messy HTML back into clean Markdown.

What Markdown becomes

MarkdownHTML
# Title<h1>Title</h1>
- item<ul><li>item</li></ul>
**bold**<strong>bold</strong>
[text](url)<a href="url">text</a>
```code```<pre><code>code</code></pre>

A converter walks your Markdown and emits the matching tags. Most tools follow GitHub-Flavored Markdown, which adds tables, task lists and fenced code blocks on top of the original spec.

Markdown to HTML

This is the common direction: you wrote a README or a blog post in Markdown and need HTML to paste into a page, an email or a CMS. Paste the Markdown, convert, and copy the HTML. A preview helps you confirm the formatting looks right before you use it.

HTML to Markdown

The reverse is handy for cleaning up. Copy a section from a web page and it arrives as a tangle of <div>s and inline styles; converting to Markdown strips it down to the words and structure you actually want for notes or documentation. Note that HTML-only details — inline CSS, complex nested tables — can’t always be expressed in Markdown, so they get simplified.

Common Markdown pitfalls

A few habits cause most “why didn’t it render?” moments:

  • Lists need a blank line before them. Glue a list directly under a paragraph and many parsers treat it as one paragraph. Leave an empty line first.
  • A single line break is usually ignored. Markdown collapses one newline into a space. For a hard break, end the line with two spaces or leave a blank line to start a new paragraph.
  • Underscores inside words can trigger italics. In some flavors snake_case_name italicizes the middle chunk. Wrap it in backticks or escape the underscores: snake\_case\_name.
  • Indenting four spaces makes a code block. Accidental indentation silently turns text into <pre> output.

Frequently asked questions

Is Markdown standardized? The closest thing to a standard is CommonMark, with GitHub-Flavored Markdown adding tables, task lists and strikethrough on top. Flavors differ, so a footnote that works on one site may not on another.

Can I put HTML inside Markdown? Yes — most renderers pass raw HTML straight through, which is handy for the odd <sub> or <details> block that Markdown can’t express. Sanitizing renderers may strip it out.

Does the output include <html> and <body>? No. Converters emit an HTML fragment — just the <h1>, <p> and so on. Wrap it in a full document yourself if you need a standalone page. For a different markup language with far stricter rules, see our guide to XML.

Do it privately, in your browser

The Markdown ⇄ HTML converter runs entirely on your device — nothing is uploaded — and shows a sandboxed live preview that renders the layout without executing any scripts. Convert either direction, preview, then copy or download.

  • Keeping an eye on length while you write? Use the word counter.
  • Pasted text full of stray line breaks? Tidy it with the text cleaner.