Markdown Preview

Markdown on the left, rendered HTML on the right. The renderer is small on purpose — no external library, no CDN dependency.

Rendered HTML
—
Preview (raw HTML below is escaped, this is the live render)
—

Worked example

The renderer escapes HTML first, then applies Markdown patterns. That order matters: a blog comment containing a <script> tag arrives as text rather than executing.

Markdown is a formatting convention, not a file format — the same source can render differently in GitHub, in a static site generator and in a chat app, because each implements a slightly different dialect. This previewer implements the common subset.

What this supports

Headings, bold, italic, inline code, fenced code blocks, unordered and ordered lists, blockquotes, horizontal rules, links and paragraphs. Code blocks are extracted before any other rule runs, so asterisks inside code stay literal.

What it deliberately omits

Raw HTML passthrough, footnotes, definition lists, tables and task lists. Raw HTML is the big one: allowing it in a preview tool is how an XSS demonstration becomes an XSS incident when someone pastes their own content.

The escaping order

Angle brackets and ampersands are escaped before Markdown patterns are applied. If that order were reversed, Markdown-generated tags would be escaped too and nothing would render — a mistake that shows up as a page full of visible HTML tags.