PHPackages                             kreuzberg-dev/html-to-markdown - 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. kreuzberg-dev/html-to-markdown

ActivePhp-ext[Parsing &amp; Serialization](/categories/parsing)

kreuzberg-dev/html-to-markdown
==============================

High-performance HTML to Markdown converter

v3.5.7(1mo ago)7906261[4 PRs](https://github.com/kreuzberg-dev/html-to-markdown/pulls)MITHTMLPHP &gt;=8.2CI failing

Since Nov 3Pushed 4d ago6 watchersCompare

[ Source](https://github.com/kreuzberg-dev/html-to-markdown)[ Packagist](https://packagist.org/packages/kreuzberg-dev/html-to-markdown)[ RSS](/packages/kreuzberg-dev-html-to-markdown/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (28)Versions (191)Used By (0)

   ![Xberg](https://camo.githubusercontent.com/634e91576caf8f36ad27ce2180030b6dcd54a71dc87f7be493855aebfc430d5b/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f78626572672d696f2f6173736574734076312f62616e6e65722f726561646d652d62616e6e65722d6c696768742e737667)

html-to-markdown
================

[](#html-to-markdown)

 [ ![Built with alef](https://camo.githubusercontent.com/c9e1dfcbc5066304dc7bd3d619f0bea998c7cb09c2301107c1b867345d5c6d2a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c74253230776974682d616c65662532302544372539302d303037656336) ](https://github.com/xberg-io/alef) [ ![Rust](https://camo.githubusercontent.com/875152826f78912b6caa083335bd4da698c60b03d9c1928a79f6ccc3d0f43c34/68747470733a2f2f696d672e736869656c64732e696f2f6372617465732f762f68746d6c2d746f2d6d61726b646f776e2d72733f6c6162656c3d5275737426636f6c6f723d303037656336) ](https://crates.io/crates/html-to-markdown-rs) [ ![Python](https://camo.githubusercontent.com/37b516d01cb111f0df23c1489fcfbc5580c626199b7ace3f49c2d4e9bfd13cc1/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f68746d6c2d746f2d6d61726b646f776e3f6c6162656c3d507974686f6e26636f6c6f723d303037656336) ](https://pypi.org/project/html-to-markdown/) [ ![Node.js](https://camo.githubusercontent.com/f6bfbaf34c89152dea667d528eecba526094ca3c4159d4a05d21b42076562aa2/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f4078626572672d696f2f68746d6c2d746f2d6d61726b646f776e3f6c6162656c3d4e6f64652e6a7326636f6c6f723d303037656336) ](https://www.npmjs.com/package/@xberg-io/html-to-markdown) [ ![WASM](https://camo.githubusercontent.com/23f0057ec0e72d38720f6897f3007b1a35b192ba5af639fd64bc9be6433e486b/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f4078626572672d696f2f68746d6c2d746f2d6d61726b646f776e2d7761736d3f6c6162656c3d5741534d26636f6c6f723d303037656336) ](https://www.npmjs.com/package/@xberg-io/html-to-markdown-wasm) [ ![Java](https://camo.githubusercontent.com/e223372f634c387818068f5195fffbd29d6ac479c79d2a43909ca4f420c14fae/68747470733a2f2f696d672e736869656c64732e696f2f6d6176656e2d63656e7472616c2f762f696f2e78626572672f68746d6c2d746f2d6d61726b646f776e3f6c6162656c3d4a61766126636f6c6f723d303037656336) ](https://central.sonatype.com/artifact/io.xberg/html-to-markdown) [ ![Go](https://camo.githubusercontent.com/d4ca576527607331d4415ed762e5352c02e8317750787c10f76b8fef5101b8d7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f78626572672d696f2f68746d6c2d746f2d6d61726b646f776e3f6c6162656c3d476f26636f6c6f723d3030376563362666696c7465723d76332a) ](https://pkg.go.dev/github.com/xberg-io/html-to-markdown/packages/go/v3) [ ![C#](https://camo.githubusercontent.com/223ad3e8bc24c3b8069399203c0ede90b7956bf6fb71b9b9757674cd389027f7/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f762f5862657267496f2e48746d6c546f4d61726b646f776e3f6c6162656c3d4325323326636f6c6f723d303037656336) ](https://www.nuget.org/packages/XbergIo.HtmlToMarkdown/) [ ![PHP](https://camo.githubusercontent.com/5a5a085aa795cfebdbaca58a2095e9e7356baa68e127576bc4dfc3aba1a546da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f78626572672d696f2f68746d6c2d746f2d6d61726b646f776e3f6c6162656c3d50485026636f6c6f723d303037656336) ](https://packagist.org/packages/xberg-io/html-to-markdown) [ ![Ruby](https://camo.githubusercontent.com/6a4b8b9f1861bb7980c818ef51e2556aba13e737033adf3d0f3165577191bae1/68747470733a2f2f696d672e736869656c64732e696f2f67656d2f762f68746d6c2d746f2d6d61726b646f776e3f6c6162656c3d5275627926636f6c6f723d303037656336) ](https://rubygems.org/gems/html-to-markdown) [ ![Elixir](https://camo.githubusercontent.com/970b7fe0422be681afedf7ea2c00c2bd2f44da7436c4679e7a6990e64ffefd44/68747470733a2f2f696d672e736869656c64732e696f2f686578706d2f762f68746d6c5f746f5f6d61726b646f776e3f6c6162656c3d456c6978697226636f6c6f723d303037656336) ](https://hex.pm/packages/html_to_markdown) [ ![R](https://camo.githubusercontent.com/f1a0b15ace52ad38450104c2a5293dd61c561fd3cbb27dbf2ba3b89cfde2010d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f522d68746d6c746f6d61726b646f776e2d303037656336) ](https://xberg-io.r-universe.dev/htmltomarkdown) [ ![Dart](https://camo.githubusercontent.com/41aa058c654c32f1c4a0a012ba89d0515a58fb6c0c878f1d5495bfe84bb46df6/68747470733a2f2f696d672e736869656c64732e696f2f7075622f762f68326d3f6c6162656c3d4461727426636f6c6f723d303037656336) ](https://pub.dev/packages/h2m) [ ![Kotlin](https://camo.githubusercontent.com/d51217c5d0ad04db5ef94ef8ebe28a3973d25ea769205ffbf84e590d3405887c/68747470733a2f2f696d672e736869656c64732e696f2f6d6176656e2d63656e7472616c2f762f696f2e78626572672f68746d6c2d746f2d6d61726b646f776e2d616e64726f69643f6c6162656c3d4b6f746c696e26636f6c6f723d303037656336) ](https://central.sonatype.com/artifact/io.xberg/html-to-markdown-android) [ ![Swift](https://camo.githubusercontent.com/b8e3c9990c66f8b878644a15e0ffd0fba03df291119bca044b94033c83d27246/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53776966742d53504d2d303037656336) ](https://github.com/xberg-io/html-to-markdown/tree/main/packages/swift) [ ![Zig](https://camo.githubusercontent.com/376558d850c9af32b9d23b0211489a0b5c979af703256fa0b7c3e917bd591c53/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5a69672d7061636b6167652d303037656336) ](https://github.com/xberg-io/html-to-markdown/tree/main/packages/zig) [ ![C FFI](https://camo.githubusercontent.com/41b9c58c3810775402965a3a7652da9832ea83391c1ff255081e5551900db8f2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f432d4646492d303037656336) ](https://github.com/xberg-io/html-to-markdown/releases) [ ![License](https://camo.githubusercontent.com/0cd4d42d83d2124c29737dd1519425c87c4b465016ef0cee20cbcb8ef420c0e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d303037656336) ](https://github.com/xberg-io/html-to-markdown/blob/main/LICENSE) [ ![Documentation](https://camo.githubusercontent.com/8531cb23a6ba930a1743eb1bf7187f9235844962722243255286ae2bd27287d9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f63732d68746d6c2d2d746f2d2d6d61726b646f776e2d303037656336) ](https://docs.html-to-markdown.xberg.io)

 [ ![Join Discord](https://camo.githubusercontent.com/c3d59355bb5f7fc8224936ba897a06b87e5ba6f52bd08dfd2f7f78bf669c550d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d436861742d3030376563363f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465) ](https://discord.gg/xt9WY3GnKR) [ ![Live Demo](https://camo.githubusercontent.com/f4ded88061eb110a708c51d9476bd2fe28b1434b3353e4dae241902beef23025/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c69766525323044656d6f2d4f70656e2d3030376563363f6c6f676f3d776562617373656d626c79266c6f676f436f6c6f723d7768697465) ](https://docs.html-to-markdown.xberg.io/demo/)

Fast, robust HTML → Markdown for 16 languages. A tiered converter that picks the safest, fastest path per input without losing content.

What and Why?
-------------

[](#what-and-why)

html-to-markdown converts real-world HTML — unclosed tags, CDATA, custom elements, malformed entities, nested tables, mixed encodings — into clean CommonMark (or Djot) without losing content, from one Rust core with native bindings for 16 languages.

It routes each input through three tiers: a single-pass byte scanner for clean HTML, a tolerant DOM walker for complex inputs, and an `html5ever` repair pass for malformed HTML — with byte-identical output across tiers, enforced by a 116-snapshot oracle and per-group performance gates in CI. The dispatcher is invisible: the same `convert()` call works regardless of which tier runs.

### Features

[](#features)

FeatureDescription**16 languages, one Rust core**Rust, Python, Node.js, WASM, Java, Go, C#, PHP, Ruby, Elixir, R, Dart, Kotlin (Android), Swift, Zig, and a C ABI**Tiered dispatch**Byte scanner → DOM walker → `html5ever` repair, with byte-equal output across tiers**Real-HTML robust**Unclosed tags, CDATA, custom elements, malformed entities, nested tables, mixed encodings — handled without losing content**GFM tables**Padded cells, alignment, and pipe escaping**Djot output**Set `output_format = "djot"` to emit Djot instead of Markdown**Metadata extraction**Parse `` into structured metadata (Open Graph, Twitter, JSON-LD, microdata, RDFa, header hierarchy)**Inline images**Opt-in mirroring of data URIs and remote image references**Visitor API**Feature-gated traversal to transform the converted Markdown AST**Configurable preprocessing**Standard, strict, and lenient presets — or build your own**Fast**19–116 MB/s on the Wikipedia/mdream corpus; per-group regression thresholds enforced on every PR [ ![Star html-to-markdown on GitHub](docs/assets/star.gif) ](https://github.com/xberg-io/html-to-markdown/stargazers)

**⭐ Star this repo to show your support — it helps others discover html-to-markdown.**

Quick Start
-----------

[](#quick-start)

`convert()` is the single entry point — it returns a structured result with `content`, `warnings`, and optional `metadata`.

### Language Packages

[](#language-packages)

**Rust**```
cargo add html-to-markdown-rs
```

See [Rust README](https://github.com/xberg-io/html-to-markdown/tree/main/crates/html-to-markdown) for full documentation.

**Python**```
pip install html-to-markdown
```

See [Python README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/python) for full documentation.

**Node.js**```
npm install @xberg-io/html-to-markdown
```

See [Node.js README](https://github.com/xberg-io/html-to-markdown/tree/main/crates/html-to-markdown-node) for full documentation.

**Go**```
go get github.com/xberg-io/html-to-markdown/packages/go/v3
```

See [Go README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/go) for full documentation.

**Java**Available on Maven Central as `io.xberg:html-to-markdown`. See [Java README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/java) for the dependency snippet and current version.

**C#**```
dotnet add package XbergIo.HtmlToMarkdown
```

See [C# README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/csharp) for full documentation.

**Ruby**```
gem install html-to-markdown
```

See [Ruby README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/ruby) for full documentation.

**PHP**This is a native PHP extension (Rust `ext-php-rs`), so install it with [PIE](https://github.com/php/pie) — not `composer require`:

```
pie install xberg-io/html-to-markdown
```

See [PHP README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/php) for full documentation.

**Elixir**Add `{:html_to_markdown, "~> 3.6"}` to your `mix.exs` dependencies. See [Elixir README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/elixir) for full documentation.

**R**```
install.packages("htmltomarkdown", repos = "https://xberg-io.r-universe.dev")
```

See [R README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/r) for full documentation.

**Dart / Flutter**```
dart pub add h2m
```

See [Dart README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/dart) for full documentation.

**Kotlin (Android)**Available on Maven Central as `io.xberg:html-to-markdown-android`. See [Kotlin README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/kotlin-android) for the dependency snippet and current version.

**Swift**Add via Swift Package Manager. See [Swift README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/swift) for full documentation.

**Zig**See [Zig README](https://github.com/xberg-io/html-to-markdown/tree/main/packages/zig) for installation and usage.

**WebAssembly**```
npm install @xberg-io/html-to-markdown-wasm
```

See [WebAssembly README](https://github.com/xberg-io/html-to-markdown/tree/main/crates/html-to-markdown-wasm) for full documentation.

**C/C++ (FFI)**Pre-built `.so` / `.dll` / `.dylib` from [GitHub Releases](https://github.com/xberg-io/html-to-markdown/releases). See [FFI crate](https://github.com/xberg-io/html-to-markdown/tree/main/crates/html-to-markdown-ffi) for full documentation.

**CLI**```
cargo install html-to-markdown-cli
```

```
brew install xberg-io/tap/html-to-markdown
```

See [CLI usage](https://docs.html-to-markdown.xberg.io) for full documentation.

### AI Coding Assistants

[](#ai-coding-assistants)

Install the html-to-markdown plugin from the [`xberg-io/plugins`](https://github.com/xberg-io/plugins) marketplace. It ships the html-to-markdown agent skills and works with every major coding agent — expand your harness below.

**Claude Code**```
/plugin marketplace add xberg-io/plugins
/plugin install html-to-markdown@xberg-io

```

**Codex CLI**```
/plugins add https://github.com/xberg-io/plugins

```

Then search for `html-to-markdown` and select **Install Plugin**.

**Cursor**Settings → Plugins → Add from URL → `https://github.com/xberg-io/plugins`, then select **html-to-markdown**.

**Gemini CLI**```
gemini extensions install https://github.com/xberg-io/plugins

```

**Factory Droid**```
droid plugin marketplace add https://github.com/xberg-io/plugins
droid plugin install html-to-markdown@xberg-io

```

**GitHub Copilot CLI**```
copilot plugin marketplace add https://github.com/xberg-io/plugins
copilot plugin install html-to-markdown@xberg-io

```

**opencode**Add the package to `opencode.json`:

```
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@xberg-io/opencode-html-to-markdown"]
}
```

Documentation
-------------

[](#documentation)

Full guides, the `convert()` API for every binding, tier architecture, the metadata and visitor APIs, and performance benchmarks live at **[docs.html-to-markdown.xberg.io](https://docs.html-to-markdown.xberg.io)**.

Part of Xberg
-------------

[](#part-of-xberg)

- [Xberg](https://github.com/xberg-io/xberg) — document intelligence: text, tables, metadata from 91+ formats with optional OCR.
- [Xberg Enterprise](https://github.com/xberg-io/xberg-enterprise) — managed extraction API with SDKs, dashboards, and observability.
- [crawlberg](https://github.com/xberg-io/crawlberg) — web crawling and scraping with HTML→Markdown and headless-Chrome fallback.
- [html-to-markdown](https://github.com/xberg-io/html-to-markdown) — fast, lossless HTML→Markdown engine.
- [liter-llm](https://github.com/xberg-io/liter-llm) — universal LLM API client with native bindings for 14 languages and 143 providers.
- [tree-sitter-language-pack](https://github.com/xberg-io/tree-sitter-language-pack) — tree-sitter grammars and code-intelligence primitives.
- [alef](https://github.com/xberg-io/alef) — the polyglot binding generator that produces every per-language binding across the 5 polyglot repos.

Contributing
------------

[](#contributing)

Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions and guidelines.

License
-------

[](#license)

MIT License — see [LICENSE](LICENSE) for details.

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community30

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 85.3% 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

Every ~1 days

Total

135

Last Release

31d ago

Major Versions

v2.15.0 → v4.0.0-rc.162025-12-22

2.30.0 → v3.x-dev2026-03-30

PHP version history (3 changes)v2.5.7PHP ^8.2

2.24.6PHP ^8.4

v3.5.0-rc.1PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30733348?v=4)[Na'aman Hirschfeld](/maintainers/Goldziher)[@Goldziher](https://github.com/Goldziher)

---

Top Contributors

[![Goldziher](https://avatars.githubusercontent.com/u/30733348?v=4)](https://github.com/Goldziher "Goldziher (2353 commits)")[![AlexVonB](https://avatars.githubusercontent.com/u/7325664?v=4)](https://github.com/AlexVonB "AlexVonB (130 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (90 commits)")[![matthewwithanm](https://avatars.githubusercontent.com/u/126263?v=4)](https://github.com/matthewwithanm "matthewwithanm (55 commits)")[![andredelft](https://avatars.githubusercontent.com/u/32297879?v=4)](https://github.com/andredelft "andredelft (13 commits)")[![kh3rld](https://avatars.githubusercontent.com/u/171191586?v=4)](https://github.com/kh3rld "kh3rld (11 commits)")[![Mkalbani](https://avatars.githubusercontent.com/u/112591148?v=4)](https://github.com/Mkalbani "Mkalbani (11 commits)")[![v-tan](https://avatars.githubusercontent.com/u/22367932?v=4)](https://github.com/v-tan "v-tan (10 commits)")[![nickovs](https://avatars.githubusercontent.com/u/4205868?v=4)](https://github.com/nickovs "nickovs (9 commits)")[![SimonIT](https://avatars.githubusercontent.com/u/11720038?v=4)](https://github.com/SimonIT "SimonIT (8 commits)")[![BrunoMiguens](https://avatars.githubusercontent.com/u/6075268?v=4)](https://github.com/BrunoMiguens "BrunoMiguens (8 commits)")[![dietervansteenwegen](https://avatars.githubusercontent.com/u/46349482?v=4)](https://github.com/dietervansteenwegen "dietervansteenwegen (6 commits)")[![pratik-mahalle](https://avatars.githubusercontent.com/u/124587957?v=4)](https://github.com/pratik-mahalle "pratik-mahalle (5 commits)")[![jfouret](https://avatars.githubusercontent.com/u/30047021?v=4)](https://github.com/jfouret "jfouret (4 commits)")[![bbeardsley](https://avatars.githubusercontent.com/u/9709?v=4)](https://github.com/bbeardsley "bbeardsley (4 commits)")[![chrispy-snps](https://avatars.githubusercontent.com/u/50950969?v=4)](https://github.com/chrispy-snps "chrispy-snps (4 commits)")[![ivanova-gif](https://avatars.githubusercontent.com/u/247880403?v=4)](https://github.com/ivanova-gif "ivanova-gif (4 commits)")[![tlp-red](https://avatars.githubusercontent.com/u/57686909?v=4)](https://github.com/tlp-red "tlp-red (4 commits)")[![jsm28](https://avatars.githubusercontent.com/u/10537793?v=4)](https://github.com/jsm28 "jsm28 (3 commits)")[![idvorkin](https://avatars.githubusercontent.com/u/280981?v=4)](https://github.com/idvorkin "idvorkin (3 commits)")

---

Tags

hocrhtmlhtml-convertermarkdownmarkdown-converterragtext-extractiontext-processinghtmlconvertermarkdown

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kreuzberg-dev-html-to-markdown/health.svg)

```
[![Health](https://phpackages.com/badges/kreuzberg-dev-html-to-markdown/health.svg)](https://phpackages.com/packages/kreuzberg-dev-html-to-markdown)
```

###  Alternatives

[league/html-to-markdown

An HTML-to-markdown conversion helper for PHP

1.9k32.2M297](/packages/league-html-to-markdown)[pixel418/markdownify

The HTML to Markdown converter for PHP

198876.3k8](/packages/pixel418-markdownify)[texy/texy

Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated against spambots), national typographic single and double quotation marks, ellipses, em dashes, dimension sign, nonbreakable spaces (e.g. in phone numbers), acronyms, arrows and many others. Texy code can optionally contain HTML tags.

161862.7k15](/packages/texy-texy)[3f/converter

A set of classes to translate a text from HTML to BBcode and from BBCode to Markdown.

29153.6k](/packages/3f-converter)[interaction-design-foundation/nova-html-card

A Laravel Nova card to display arbitrary HTML content

67863.1k4](/packages/interaction-design-foundation-nova-html-card)[kartik-v/yii2-markdown

Advanced Markdown editing and conversion utilities for Yii Framework 2.0

91273.8k6](/packages/kartik-v-yii2-markdown)

PHPackages © 2026

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