Parsedown

Fast, single-class Markdown parser for PHP with no dependencies beyond mbstring.

Library
Composer
v1.8.0
15,052stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
49/100Fair
Development Activity4
Maintenance20
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture65
Code Quality75
Innovation62
Learning Curve90

Parsedown converts Markdown to HTML in PHP using a single class with no dependencies beyond the mbstring extension, making it one of the easiest Markdown libraries to drop into any PHP project — install it and call (new Parsedown())->text($markdown). It became one of the most widely used PHP Markdown parsers largely because of that simplicity plus its speed: Parsedown avoids full tokenization passes in favor of an optimized line-based parsing approach that benchmarks faster than several alternative PHP Markdown libraries.

Beyond core Markdown, it supports a practical superset of GitHub-flavored features (tables, fenced code blocks, autolinks, strikethrough) and is commonly extended via subclassing — the companion erusev/parsedown-extra package builds Markdown Extra support (footnotes, definition lists, attributes) directly on top of it.

What You Get

  • Parsedown::text() for full document-to-HTML conversion and Parsedown::line() for inline-only parsing
  • GitHub-flavored extras beyond core Markdown: tables, fenced code blocks, autolinks, strikethrough
  • setSafeMode() to strip raw HTML/scripts for parsing untrusted user input
  • setBreaksEnabled() for GFM-style single-newline-to-<br> behavior
  • A subclassing-friendly architecture used by parsedown-extra to add footnotes, definition lists, and attributes

Common Use Cases

  • Rendering user-submitted comments, wiki pages, or README-style content to HTML in a PHP app
  • Powering flat-file and static-site CMS content pipelines (Grav, Kirby-style tools) that store content as Markdown
  • Safely rendering untrusted Markdown input via setSafeMode(true)
  • Extending via subclass to add custom Markdown syntax specific to an application

Under The Hood

Architecture: The entire library is one ~2,000-line Parsedown.php file defining a single Parsedown class; block-level constructs (headers, lists, code blocks, tables, quotes) are matched by their leading character via a dispatch table built in the constructor, then handled by paired block*()/block*Continue()/block*Complete() methods, while inline constructs (emphasis, links, code spans) are similarly dispatched by trigger character through inline*() methods — a deliberate single-pass, line-oriented design rather than a full tokenizer/AST. Tech Stack: Plain PHP with ext-mbstring as the only extension dependency, no other runtime dependencies, targeting PHP 7.2+; distributed via a PSR-0 autoload mapping (predating the now-standard PSR-4) reflecting the project’s long history. Code Quality: Despite living in a single file, the codebase is organized into clearly delimited Setup, Block Elements, Inline Elements, Handlers, and Deprecated sections with a comment banner between each; it’s tested with PHPUnit against both its own test suite and the CommonMark conformance test suite (test/CommonMarkTest), giving objective coverage of spec compliance despite the codebase’s compact single-class shape. API Design: The public surface is deliberately tiny — text(), line(), and a handful of set*() toggles — which is precisely why it became a common building block: consuming code rarely needs more than (new Parsedown())->text($input), and the class is easy to subclass for the rare case that needs more.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search