Developer Tools

Markdown to HTML: A Clean Publishing Workflow for 2026

Write in Markdown, ship semantic HTML. The conversion rules, the pitfalls (tables, code fences, sanitization), and a repeatable pipeline.

3 min read·Updated 2026-09-22

Markdown won because it reads like plain text and writes like markup — no angle brackets to typo, no closing tags to forget, and it diffs cleanly in version control. Converting it to HTML is trivial; converting it to correct, safe, consistent HTML is where workflows break down. This guide covers the conversion rules, the pitfalls, and a pipeline you can run every publish.

What maps to what

MarkdownHTMLNotes
# H1 … ###### H6<h1>…<h6>One H1 per page for SEO sanity
**bold** / *italic*<strong> / <em>Semantic, not the old <b>/<i>
[text](url)<a href>Relative links stay relative in static builds
- item / 1. item<ul> / <ol>Nested items indent with 2–4 spaces
> quote<blockquote>Nested quotes stack the marker
Fenced ``` blocks<pre><code>Add a language class for highlighting
Pipe tables<table>Alignment via :--- markers
---<hr>Also setext heading underline under text
![alt](img)<img>alt text is an accessibility requirement, not a suggestion

The pitfalls

  • Line breaks vanish. Standard Markdown joins consecutive lines into one paragraph — end lines with two spaces or a backslash, or use blank lines.
  • Raw HTML passes through. Useful for embeds, dangerous for user input: untrusted Markdown must be sanitized (allowlist tags/attributes) or you ship XSS.
  • Code fences inside HTML blocks — indentation-based HTML parsing and fenced code interact badly in some engines. Keep fences at column zero.
  • Tables need pipes everywhere. A missing trailing pipe breaks the row silently in some parsers.
  • Smart punctuation differs by engine — -- may become an en dash on one platform and literal on another. Test the render, don't assume.

A repeatable pipeline

  1. Write in any editor with a live preview — keep Markdown in git, always.
  2. Convert — run the document through the Markdown to HTML converter; check the preview, copy the semantic output.
  3. Sanitize if the Markdown came from anyone but you — allowlist <p> <a> <em> <strong> <ul> <ol> <li> <blockquote> <code> <pre> <table> headings.
  4. Review the diff — paste old and new HTML into the Diff Checker to catch unintended changes (dropped attributes, mangled entities) before deploy.
  5. Validate once — W3C validator or tidy -errors catches unclosed tags that browsers forgive silently.

When to stay in Markdown

Docs, changelogs, READMEs, CMS content and anything reviewed in pull requests — Markdown diffs are readable; minified HTML diffs are noise. Ship HTML only where the consumer needs markup (embeds, emails with tables, structured data injection).

Frequently asked questions

Which dialect should I standardize on? CommonMark + GFM tables and task lists covers ~95% of real usage and is supported by every serious engine.

How do I handle footnotes or mermaid diagrams? GFM footnotes where supported; diagrams render via client-side libraries — both are extensions, so pick engines that agree on them across your toolchain.

Is converted HTML SEO-neutral? Yes, provided the structure is semantic (real headings, lists, alt text). Search engines read the DOM — they don't care which editor produced it.

Tools used in this guide

Related guides