Markdown to HTML Converter

Write Markdown on the left. The examples in the title bar only fill the editor. The right pane shows the rendered preview; the bar below switches to the HTML source of that same fragment.

Markdown is a writing shorthand for an HTML fragment

A heading, a paragraph, a list, and a fenced code block are not styles. They are elements: h1–h6, p, ul or ol, and pre. Conversion walks the Markdown document and emits that fragment. The preview paints it; the HTML view is the same tags as text.

Paste the fragment into a page and tidy the surrounding markup in the HTML formatter. Class names on that page belong in the CSS formatter.

Which constructs become which elements

How block structure becomes elements

  1. A blank line ends a paragraph. A single newline inside a paragraph is a soft break, not a new p.
  2. One to six # marks at the start of a line are h1 through h6. The number of marks is the level.
  3. A line that starts with -, *, or a number plus a dot is a list item. Nested items need deeper indent.
  4. A line of --- or *** on its own is a thematic break, hr, not a text rule you style later.

How emphasis, links, and images are written

  1. **text** becomes strong. *text* becomes em. The markers must hug the words.
  2. [label](url) is an anchor. The URL is copied as written, including a relative path.
  3. ![alt](url) is an image. The alt text is the accessible name, not a caption element.
  4. A bare URL is not always a link. Autolink is a separate rule from an explicit [label](url).

How fenced code and GFM tables differ from plain paragraphs

  1. A fence of three backticks wraps a pre/code block. An optional info string such as js names the language, it does not execute the code.
  2. Four-space indent is also a code block. It is easy to create by accident when a paragraph is indented.
  3. A GFM table is a header row, a delimiter row of dashes, then body rows. Cells are td or th, not a layout grid.
  4. Strikethrough with ~~text~~ is a GFM span, del, not part of the original CommonMark core.

Why the preview and the HTML source are the same fragment

  1. Preview is the browser painting the fragment. Source is that fragment serialized as tags.
  2. Switching views does not run a second conversion.
  3. A raw HTML block inside the Markdown is emitted as HTML, not escaped into text.
  4. The fragment has no html, head, or body wrapper. Those belong to the page you paste into.

Where the fragment is used

README and docs

Headings, lists, and fenced samples become the elements a docs site already styles.

CMS body fields

The source view is the snippet to paste. The preview is only how the fragment paints before your stylesheet.

Frequently asked questions

How does Markdown become HTML?
Each block and span maps to an element: headings to h1–h6, paragraphs to p, lists to ul or ol, fences to pre/code.
Why does a single line break not make a new paragraph?
A blank line separates paragraphs. One newline inside a paragraph is a soft break.
What is a fenced code block?
Three backticks open and close a pre/code block. The word after the opening fence is a language label, not a program that runs.
Do tables convert?
A GitHub-flavored table (header, dash row, body) becomes a table element. A row of pipes without the dash row stays text.
Is the preview different HTML from the source view?
No. Preview paints the fragment. The HTML view shows those same tags.
Does **bold** always become strong?
When the markers sit against the words. A space inside the markers, or a marker on only one side, stays literal text.
What happens to raw HTML in the Markdown?
It is copied into the fragment rather than escaped. The result is not a tag-stripped subset of Markdown.
Where should the fragment go?
Into the body of a page. Shape the surrounding document in the HTML formatter and the classes in the CSS formatter.