HTML to Markdown

Convert HTML to clean Markdown, or Markdown to HTML with a safe preview: headings, lists, links, images, code blocks and GFM tables, entirely in your browser.

About this tool

Documentation, blog posts and knowledge-base articles often start life as HTML, but notes apps, static site generators, READMEs and wikis want Markdown. This tool converts in both directions in your browser. HTML to Markdown walks the parsed HTML and writes headings, bold and italic text, links, images, nested and numbered lists, task-list checkboxes, blockquotes, fenced code blocks (keeping a language-xxx class as the fence language) and GFM tables, with the table alignment kept. Markdown to HTML renders GitHub-flavored Markdown with a source view and a sandboxed preview. Nothing you paste is uploaded.

How to use it

  1. Choose HTML to Markdown or Markdown to HTML at the top, then paste into the input box. In HTML mode you can also copy text straight from a web page and paste it: the tool converts the copied rich content instead of showing raw tags.
  2. In HTML mode, pick the list marker (-, * or +), the emphasis style (*italic* or _italic_) and whether to keep images. In Markdown mode, choose whether to strip scripts, iframes and event handlers from the generated HTML (on by default).
  3. Read the result in the output box. In Markdown mode, switch between Source and Preview to see the rendered page.
  4. Click Copy, or Use as input to send the result back through the converter in the other direction and check that it round-trips.

FAQ

Which HTML elements are converted?

Headings h1 to h6, paragraphs, strong/b, em/i, del/s, inline code, pre blocks (with the language taken from a language-xxx class), links, images, ul and ol lists with any nesting (ordered lists keep their start number), task-list checkboxes, blockquotes, hr, br, tables and definition lists. Wrapper elements such as div, section, article and span are unwrapped and only their content is kept.

What is lost in the conversion?

Markdown cannot express everything HTML can, so styling is dropped: colors, fonts, inline CSS, classes and ids, table cell merges (colspan and rowspan) and nested tables inside cells. Script, style, iframe, svg, canvas, button and form-control elements are removed. If a table has no header row, its first row is used as the header because GFM tables require one.

How are special characters handled?

Characters that Markdown would otherwise interpret, such as asterisks, backticks, square brackets, a leading # or - at the start of a line, and underscores at word edges, are backslash-escaped so the text renders as written. Underscores inside words like snake_case are left alone. A pipe inside a table cell is escaped as \|.

Is pasted HTML run in my browser?

No. The HTML is parsed into an inert document with the browser DOMParser, which does not execute scripts or load images, and the converter only reads its text and attributes. In Markdown to HTML mode the preview is shown in an iframe with the sandbox attribute and no permissions, so even unsanitized output cannot run code.

What does the sanitize option remove?

It removes script, iframe, object, embed, link, style, meta, base and form elements, every on-event attribute such as onclick, and javascript: links in href and src. It is a basic safety net for output you plan to paste into a page, not a replacement for a dedicated sanitizer with an allow-list when you publish untrusted content.

Which Markdown flavor does Markdown to HTML use?

GitHub-flavored Markdown through the marked library, so tables, task lists, strikethrough and fenced code blocks work. Single line breaks are not turned into br tags, as in standard Markdown, and raw HTML inside your Markdown is passed through (and sanitized when that option is on).

How is this different from the Markdown Previewer or Markdown to PDF?

The Markdown Previewer shows how Markdown looks, and Markdown to PDF turns it into a document. This tool is about converting the source text itself: HTML into Markdown you can edit and commit, or Markdown into HTML source you can copy into a template.

Is my content uploaded anywhere?

No. Parsing and conversion run in your browser tab. Only the Markdown renderer script is downloaded from a CDN the first time you use Markdown to HTML; your text is never sent to it.

Related tools

Guides & comparisons

← All tools · Text & Data · Blog · Cheat sheets · FAQ