Eskillsfy

Home / Blog / Web and CSS

Web and CSS · 23 Nov 2026

Markdown Preview: how it works and how to build one

Write Markdown and see the result, then copy the HTML. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Live preview of GitHub-flavoured Markdown, including tables, task lists and code blocks. Open a README to check it before you push, or export the HTML.

When to use it

  • Writing READMEs
  • Drafting blog posts
  • Checking GitHub formatting before you push

How to use it

  1. Type Markdown or open a .md file.
  2. Watch the preview update.
  3. Copy or download the HTML.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/markdown-preview

How it works

The preview parses Markdown into HTML with ‘marked’ on every keystroke and puts it into the page. Because Markdown can contain raw HTML, the result is sanitised first: script tags, event handlers like onclick and javascript: links are removed.

Styling comes from a .md class that sets spacing for headings, lists, tables and code.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any React project.

MarkdownPreview.tsx (tsx)

import { marked } from "marked";
import DOMPurify from "dompurify";
import { useMemo, useState } from "react";

export function MarkdownPreview() {
  const [md, setMd] = useState("# Hello\n\n**Markdown** preview");
  const html = useMemo(() => DOMPurify.sanitize(marked.parse(md, { async: false }) as string), [md]);
  return (
    <div className="split">
      <textarea value={md} onChange={(e) => setMd(e.target.value)} />
      <article className="md" dangerouslySetInnerHTML={{ __html: html }} />
    </div>
  );
}

Make it production-ready

  • Sync scrolling between the two panes.
  • Export the HTML or a PDF.

Questions

Is it GitHub-flavoured?

Yes: tables, strikethrough, task lists and fenced code blocks all work.

Try the Markdown Preview

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Web and CSS

All posts