PHPackages                             mistralys/simple\_html\_dom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mistralys/simple\_html\_dom

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

mistralys/simple\_html\_dom
===========================

A fast, forgiving HTML parser for PHP.

2.0.0(1mo ago)021↑185.7%1MITPHPPHP ^8.4

Since May 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Mistralys/simple_html_dom)[ Packagist](https://packagist.org/packages/mistralys/simple_html_dom)[ Docs](https://github.com/Mistralys/simple_html_dom)[ RSS](/packages/mistralys-simple-html-dom/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (1)

PHP Simple HTML DOM Parser
==========================

[](#php-simple-html-dom-parser)

A fast, forgiving HTML parser for PHP 8.4+ that lets you find and manipulate HTML elements using CSS-like selectors — no ext-dom required.

✨ Features
----------

[](#-features)

- **CSS-like selectors** — find elements by tag, `#id`, `.class`, `[attribute]`, and more
- **Two APIs, one engine** — use procedural functions (`str_get_html`, `file_get_html`) or the namespaced OOP interface (`Parser`, `Node`)
- **Forgiving parser** — handles messy, real-world HTML without choking
- **Read and modify** — change attributes, inner/outer HTML, and serialize back to string or file
- **Tree traversal** — navigate parents, children, and siblings
- **Callbacks** — hook into serialization with per-node callback functions
- **Charset conversion** — automatic detection and conversion via `ext-mbstring`
- **Configurable** — adjust max file size, encoding, and parser behavior at runtime
- **Fully backward compatible** — legacy `simple_html_dom` code works without changes

📋 Requirements
--------------

[](#-requirements)

- PHP 8.4+
- `ext-mbstring`

🚀 Quick Start
-------------

[](#-quick-start)

Install via Composer:

```
composer require shark/simple_html_dom
```

> **Note:** If the package is not available on Packagist, add the repository to your `composer.json`:
>
> ```
> "repositories": [{ "type": "vcs", "url": "https://github.com/Mistralys/simple_html_dom.git" }]
> ```

Parse HTML and find elements:

```
use SimpleHtmlDom\Parser;

$html = new Parser('OneTwo');

// Find by CSS selector
$active = $html->find('li.active', 0);
echo $active->plaintext; // "One"

// Modify and output
$active->class = 'done';
echo $html->save(); // OneTwo
```

Or use the procedural API:

```
$html = str_get_html('Hello World');
echo $html->find('b', 0)->plaintext; // "World"
```

📖 Learn More
------------

[](#-learn-more)

ResourceDescription**[Manual](manual/README.md)**Full documentation — 14 guides covering selectors, DOM traversal, modification, configuration, and more**[Examples](examples/README.md)**16 runnable PHP scripts organized by topic**[Changelog](changelog.md)**Version history and recent changes### Development

[](#development)

```
composer install       # Install dev dependencies
composer test          # Run the full test suite (PHPUnit 12.x)
composer analyze       # Run static analysis (PHPStan Level 6)
```

📜 License
---------

[](#-license)

[MIT](LICENSE)

🔗 Origin
--------

[](#-origin)

Fork of [samacs/simple\_html\_dom](https://github.com/samacs/simple_html_dom), originally by S.C. Chen ([SourceForge](http://simplehtmldom.sourceforge.net/)).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance93

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

33d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8895528?v=4)[Mistralys](/maintainers/Mistralys)[@Mistralys](https://github.com/Mistralys)

---

Top Contributors

[![Mistralys](https://avatars.githubusercontent.com/u/8895528?v=4)](https://github.com/Mistralys "Mistralys (31 commits)")[![samacs](https://avatars.githubusercontent.com/u/48268?v=4)](https://github.com/samacs "samacs (16 commits)")[![dbetts](https://avatars.githubusercontent.com/u/155651?v=4)](https://github.com/dbetts "dbetts (1 commits)")[![dzuelke](https://avatars.githubusercontent.com/u/27900?v=4)](https://github.com/dzuelke "dzuelke (1 commits)")[![pau1phi11ips](https://avatars.githubusercontent.com/u/677264?v=4)](https://github.com/pau1phi11ips "pau1phi11ips (1 commits)")[![sdufel](https://avatars.githubusercontent.com/u/578947?v=4)](https://github.com/sdufel "sdufel (1 commits)")

---

Tags

htmlparserphp-libraryphpparserhtmldom

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mistralys-simple-html-dom/health.svg)

```
[![Health](https://phpackages.com/badges/mistralys-simple-html-dom/health.svg)](https://phpackages.com/packages/mistralys-simple-html-dom)
```

###  Alternatives

[sunra/php-simple-html-dom-parser

Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.

1.3k9.6M63](/packages/sunra-php-simple-html-dom-parser)[simplehtmldom/simplehtmldom

A fast, simple and reliable HTML document parser for PHP.

1931.3M15](/packages/simplehtmldom-simplehtmldom)[ressio/pharse

Fastest PHP HTML Parser

8582.2k](/packages/ressio-pharse)[oscarotero/html-parser

Parse html strings to DOMDocument

165.4M1](/packages/oscarotero-html-parser)[hexydec/htmldoc

A token based HTML document parser and minifier. Minify HTML documents including inline CSS, Javascript, and SVG's on the fly. Extract document text, attributes, and fragments. Full test suite.

2610.8k4](/packages/hexydec-htmldoc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
