DevFormatter

Markdown Preview

Markdown
Preview

Markdown is a lightweight plain-text markup language created by John Gruber in 2004 that converts simple punctuation into formatted HTML — # for headings, **bold**, _italic_, and - for lists. It is the default writing format for GitHub READMEs, documentation sites, Jupyter notebooks, and static site generators like Jekyll and Hugo.

How it works

Markdown is a lightweight plain-text format created by John Gruber in 2004. It uses simple punctuation — # for headings, **bold**, - lists — that compiles cleanly to HTML. It is the default writing format for GitHub READMEs, documentation sites, and most developer tools.

This tool renders Markdown to HTML in real time using the marked library with GitHub Flavored Markdown (GFM) enabled — supporting tables, fenced code blocks with language labels, strikethrough, and task list checkboxes.

Switch between Split (editor + preview side-by-side), Preview (full-width rendered output), and Source (editor only) using the toolbar buttons.

Last updated: November 2026

Markdown Quick Reference

Element Markdown Output
Heading 1# TitleTitle
Heading 2## SectionSection
Bold**text**text
Italic_text_ or *text*text
Strikethrough (GFM)~~text~~text
Inline code`code`code
Code block (GFM)```js … ```highlighted block
Link[label](url)label
Image![alt](url)img element
Blockquote> quotequote
Horizontal rule---─────
Task list (GFM)- [x] done☑ done

Tips & Tricks

Two spaces = line break

A single newline in Markdown does NOT create a paragraph break — it is treated as a space. Add a blank line between paragraphs, or end a line with two spaces to force a <br> line break.

Escape special chars with \

To display a literal * # [ ] ( ) ` _ ~ backslash without formatting, prefix it with a backslash: \* prints an asterisk. This applies to any character Markdown treats as syntax.

GFM tables need a header separator

The | --- | row is mandatory in GFM tables. Without it, Markdown does not recognise the block as a table. At least one hyphen per cell is required; extra hyphens only affect readability.

Footnotes via raw HTML

Standard Markdown and GFM do not support footnotes. Use raw HTML anchor links: <sup><a href="#fn1">1</a></sup> in the text, then <p id="fn1">1. Footnote text</p> at the bottom.

Copy HTML for embedding

The Copy HTML button copies the rendered HTML output. Paste it directly into a CMS, email template, or static site — no Markdown parser needed at the destination.

Word count excludes code

The word counter strips fenced code blocks and inline code before counting, so pasted code snippets do not inflate your word count. Good for targeting documentation word-count goals.

Code Examples

Node.js — marked

const { marked } = require('marked');

const markdown = `# Hello World
This is **bold** and _italic_ text.`;

const html = marked.parse(markdown);
console.log(html);
// 

Hello World

//

This is bold and italic text.

Python — markdown

import markdown

md = """# Hello World
This is **bold** and _italic_ text.
"""

html = markdown.markdown(md, extensions=['tables', 'fenced_code'])
print(html)

CLI — pandoc

# Install pandoc (macOS)
brew install pandoc

# Convert Markdown file to HTML
pandoc README.md -o README.html

# Convert to standalone HTML with styling
pandoc README.md -s -o README.html --css styles.css

# Convert to PDF (requires LaTeX)
pandoc README.md -o README.pdf

Frequently Asked Questions

What is Markdown?

Markdown is a lightweight markup language created by John Gruber in 2004. It uses plain-text characters like # for headings, ** for bold, and - for lists to add formatting that converts to HTML. Markdown is the default format for GitHub READMEs, documentation sites (Docusaurus, MkDocs), Jupyter notebooks, and most developer tools. Gruber designed it with two goals: it should be readable as plain text without looking like it has been marked up with tags, and it should be easily convertible to structurally valid HTML. The original Perl script (Markdown.pl) was released alongside the spec in 2004. Since then, dozens of implementations have appeared in every major language. The key insight is that Markdown notation mirrors conventions already used in plain-text emails and forum posts — asterisks around *emphasis*, dashes for bullet points — making it feel intuitive to new users immediately.

What is GitHub Flavored Markdown (GFM)?

GFM is GitHub's extension of the original Markdown spec. It adds fenced code blocks with language syntax labels (```js), tables (| col | col |), strikethrough (~~text~~), task list checkboxes (- [ ] item), and auto-linking of URLs. GFM is the most widely used Markdown dialect and is used by GitHub, GitLab, and most documentation platforms. GitHub published the GFM specification formally in 2017, based on the CommonMark spec with additions. One important GFM behaviour to know: unlike original Markdown, GFM treats single newlines within a paragraph as hard line breaks when the "breaks" option is enabled (not the default in marked v5). Auto-linking in GFM means that a bare URL like https://example.com is converted to a clickable link without needing the [label](url) syntax. Task lists (- [x] item) render as interactive checkboxes on GitHub issues and pull requests.

How do I create a table in Markdown?

Use pipes to separate columns and hyphens for the header separator: | Name | Age | then | --- | --- | then | Alice | 30 |. Colons in the separator control alignment: :--- for left, ---: for right, :---: for centre. Tables are a GFM extension and are not in original Markdown. At least one hyphen per cell in the separator row is required — the number of hyphens beyond one affects only the visual alignment in the raw source, not the rendered output. Leading and trailing pipe characters are optional but strongly recommended for readability. Cells can contain inline Markdown (bold, italic, code) but not block elements like headings or code fences. For complex tables, consider using raw HTML — a GFM parser will pass through a valid HTML table unchanged. Tools like Markdown Table Generator can help create the pipe syntax from a visual grid.

What is the difference between Markdown and HTML?

Markdown is human-readable shorthand that compiles to HTML. While HTML uses verbose tags like &lt;h1&gt;Title&lt;/h1&gt;, Markdown uses # Title. Markdown is designed for writing; HTML is designed for rendering. Most Markdown parsers also allow raw HTML embedded directly in the Markdown source. The key difference for writers is cognitive load: Markdown lets you focus on content structure without manually opening and closing tags. For developers, Markdown is preferable for content that needs to be human-editable in a text editor, stored in version control, or diffed meaningfully in pull requests — none of which are practical with raw HTML. The limitation is that Markdown can only express a subset of HTML; for layout-heavy content (multi-column grids, custom CSS classes), you will eventually need to drop back to raw HTML inline within the Markdown source.

Can I embed raw HTML in Markdown?

Yes. The marked library used here passes raw HTML through to the output unchanged. You can embed &lt;div&gt;, &lt;table&gt;, &lt;span&gt;, or any HTML element directly in your Markdown source. This is useful for elements Markdown cannot express, like centred images or custom styling. For example, to centre an image you can write &lt;p align="center"&gt;&lt;img src="logo.png" width="200"&gt;&lt;/p&gt; directly in the Markdown file. Important security caveat: when rendering user-supplied Markdown in a web application, never pass the raw HTML output directly to innerHTML without sanitising it first — doing so enables cross-site scripting (XSS) attacks. Use a sanitiser like DOMPurify (npm install dompurify) on the rendered HTML before inserting it into the page. GitHub and most hosted Markdown renderers strip dangerous tags like script automatically.

How do I add a code block in Markdown?

For a fenced code block, wrap your code in triple backticks and optionally specify the language: ```python then your code then ```. For inline code, wrap with single backticks: `variable_name`. Fenced code blocks are a GFM extension; original Markdown uses 4-space indentation. The language identifier after the opening fence (e.g. ```javascript, ```bash, ```sql) is used by syntax highlighters like highlight.js and Prism to apply language-specific token colouring. The identifier is passed as a class on the generated pre code element (class="language-javascript"), so any highlighter that reads that convention will colour it correctly. For shell commands, use ```bash or ```sh; for YAML, use ```yaml; for Dockerfile content, use ```dockerfile. If you omit the language identifier, the block renders as monospace text without syntax colouring.

How do I add an image in Markdown?

Use the image syntax: ![alt text](image-url). The alt text appears if the image fails to load and is read by screen readers. Markdown has no built-in way to control image dimensions — use a raw HTML &lt;img&gt; tag with width/height attributes if sizing is needed. For example: &lt;img src="diagram.png" alt="Architecture diagram" width="600"&gt;. Well-written alt text is important for accessibility (WCAG 2.1) and SEO — describe the content of the image concisely rather than using generic phrases like "image" or "photo". For images stored in the same repository, use a relative path: ![Logo](./assets/logo.png). Some Markdown platforms (Notion, Obsidian) support an extended image syntax with size hints: ![alt|600](url), but this is not part of the GFM spec and will not render correctly on GitHub or in this tool.

What Markdown flavors exist?

The main flavors are: CommonMark (strict, unambiguous spec), GitHub Flavored Markdown (GFM, adds tables and task lists), MultiMarkdown (footnotes, citations), Pandoc Markdown (academic features), and kramdown (used by Jekyll/GitHub Pages). This tool uses marked which follows GFM/CommonMark. CommonMark was created in 2014 by a group including Jeff Atwood (Stack Overflow) to address the ambiguities in Gruber's original spec — the original spec had over 600 edge cases with no defined correct behaviour. GFM is a strict superset of CommonMark. kramdown is used by default in Jekyll and therefore on GitHub Pages sites. Pandoc Markdown is the most feature-rich dialect, supporting footnotes, definition lists, metadata blocks, and LaTeX math. If you are writing for a specific platform, check which dialect it uses — a table that renders perfectly in GFM may not render at all in an original-Markdown-only parser.

How do I create a task list in Markdown?

Task lists are a GFM extension. Use - [ ] for unchecked and - [x] for checked items. They render as checkboxes on GitHub, GitLab, and other GFM renderers. On GitHub specifically, task list checkboxes in issue descriptions and pull request bodies are interactive — clicking a checkbox updates the Markdown source automatically via the GitHub API without requiring a manual edit. Task list items support any inline Markdown inside them, so you can write - [x] **Fix the ~~broken~~ login bug** and the bold and strikethrough formatting will render correctly alongside the checkbox. Task lists are also used by GitHub to automatically calculate the completion percentage shown on project boards. Outside of GFM renderers, the raw characters - [ ] appear as plain text — there is no fallback checkbox rendering in environments that do not support the extension.

Is my Markdown sent to a server?

No. All rendering runs in your browser using the marked JavaScript library. No text is uploaded, stored, or logged. You can safely preview private documentation or sensitive content. The marked library (version 5+) runs entirely client-side with no network dependencies during parsing — it converts your Markdown string to an HTML string using a pure JavaScript tokeniser and renderer. You can verify the absence of outbound requests by opening your browser's DevTools Network tab while typing — no requests are triggered by the rendering process. This makes the tool suitable for previewing internal engineering documents, unreleased product announcements, confidential architecture diagrams described in Markdown, or any content that should not leave your machine.

How do I convert Markdown to HTML in Node.js?

Use the marked package: npm install marked then const { marked } = require("marked"); const html = marked.parse("# Hello"); console.log(html); // &lt;h1&gt;Hello&lt;/h1&gt;. GFM features (tables, task lists) are enabled by default in marked v5+. For TypeScript, the package ships its own types so no @types package is needed. To customise rendering — for example to add a CSS class to every code block — use a Renderer: const renderer = new marked.Renderer(); renderer.code = (code, lang) => "&lt;pre class=\"highlight\"&gt;&lt;code class=\"language-" + lang + "\"&gt;" + code + "&lt;/code&gt;&lt;/pre&gt;"; marked.setOptions({ renderer }). For sanitising the output before inserting into the DOM, use DOMPurify: document.getElementById("output").innerHTML = DOMPurify.sanitize(marked.parse(md)).

How do I convert Markdown to HTML in Python?

Use the markdown package: pip install markdown then import markdown; html = markdown.markdown(md, extensions=["tables", "fenced_code"]). For strict GFM, use the mistune or marko library instead. The standard Python markdown package supports a wide set of official extensions: codehilite (Pygments-powered syntax highlighting), toc (auto-generates a table of contents from headings), attr_list (adds HTML attributes to elements), and nl2br (converts newlines to &lt;br&gt; tags like GFM). For a stricter CommonMark/GFM-compliant implementation in Python, mistune 3.x and marko are good alternatives. Pandoc called from Python via subprocess is the most powerful option for complex documents: subprocess.run(["pandoc", "-f", "markdown", "-t", "html", "README.md"]).

Related Tools