Parsedown
| Language | PHP (7.1+ for 1.8; 5.3+ for 1.7) |
|---|---|
| License | MIT |
| Repository | github.com/erusev/parsedown |
| Documentation | parsedown.org, README |
| Depends on | ext-mbstring |
| Read / write | parses Markdown (GFM-like) to HTML |
Parsedown is one class in one file. It parses Markdown line by line and produces HTML quickly. Its syntax is close to GitHub’s: fenced code blocks, tables, strikethrough, autolinks and soft line breaks. It isn’t CommonMark-compliant, so edge cases (nested lists, emphasis rules, HTML blocks) differ from other renderers, and there’s no AST. ParsedownExtra (separate package) adds Markdown Extra features: footnotes, definition lists, abbreviations, special attributes and Markdown inside HTML.
After years of 1.8 betas, Parsedown 1.8.0 was released in 2026; a 2.0 rewrite is in beta. Safe mode is off by default.
Installation#
composer require erusev/parsedown
# optional
composer require erusev/parsedown-extra
Basic usage: convert Markdown to HTML#
<?php
require 'vendor/autoload.php';
$parsedown = new Parsedown();
$markdown = file_get_contents('README.md');
echo $parsedown->text($markdown);
line() parses a single line of inline Markdown without wrapping it in <p>:
echo $parsedown->line('Hello _Parsedown_!'); // Hello <em>Parsedown</em>!
How to render user input safely#
$parsedown = new Parsedown();
$parsedown->setSafeMode(true); // escapes raw HTML and blocks javascript: and similar links
echo $parsedown->text($userInput);
Safe mode was added in 1.7; for full protection also run the output through an HTML sanitizer such as HTML Purifier.
How to turn newlines into line breaks#
$parsedown->setBreaksEnabled(true); // single newlines become <br />
How to disable automatic links#
$parsedown->setUrlsLinked(false); // don't turn bare URLs into links
How to use footnotes and definition lists (ParsedownExtra)#
$extra = new ParsedownExtra();
echo $extra->text("Text with a note.[^1]\n\n[^1]: The note.\n\nTerm\n: Definition\n");
Tips#
- Parsedown keeps no state between calls, so one instance can render many documents.
- For CommonMark or full GFM compliance, or to work with the syntax tree, use league/commonmark.
setMarkupEscaped(true)escapes HTML without the URL checks of safe mode.