# html-to-markdown

> Convert HTML to Markdown, Djot, or plain text. Rust core (`html-to-markdown-rs`), 12 language bindings, identical output on every runtime. The same engine ships under the [kreuzberg.dev](https://kreuzberg.dev) document intelligence stack.

## Get Started

- [Installation](https://docs.html-to-markdown.kreuzberg.dev/installation/): Install the binding for your language — Rust, Python, TypeScript, Go, Ruby, PHP, Java, C#, Elixir, R, C, or WebAssembly.
- [Usage](https://docs.html-to-markdown.kreuzberg.dev/usage/): The `convert()` call and `ConversionResult` shape across bindings.
- [CLI](https://docs.html-to-markdown.kreuzberg.dev/cli/): Command-line wrapper with every conversion option as a flag.

## Guides

- [Visitor pattern](https://docs.html-to-markdown.kreuzberg.dev/visitor/): Intercept the DOM walk with `HtmlVisitor` to skip, replace, or preserve any element.
- [Table extraction](https://docs.html-to-markdown.kreuzberg.dev/tables/): Structured `result.tables` with cells, spans, and header flags alongside the rendered Markdown.
- [Error handling](https://docs.html-to-markdown.kreuzberg.dev/errors/): The `ConversionError` variants and how each binding surfaces them.

## Concepts

- [Architecture](https://docs.html-to-markdown.kreuzberg.dev/concepts/architecture/): Workspace layout, direct vs C-FFI bindings, feature flags, thread safety.
- [Conversion pipeline](https://docs.html-to-markdown.kreuzberg.dev/concepts/pipeline/): The five stages of `convert()` — preprocess, parse, single-pass DOM walk, post-process, extract.
- [Plugin system](https://docs.html-to-markdown.kreuzberg.dev/concepts/plugin-system/): The `HtmlVisitor` trait with 42 element-level callbacks and `VisitResult::{Continue, Custom, Skip, PreserveHtml, Error}`.

## Reference

- [Configuration](https://docs.html-to-markdown.kreuzberg.dev/configuration/): Every `ConversionOptions` field with type and default.
- [API reference](https://docs.html-to-markdown.kreuzberg.dev/api-reference/): Generated API pages from the Rust source.
- [Language guides](https://docs.html-to-markdown.kreuzberg.dev/language-guides/): Per-language install notes, naming conventions, and idiom mapping.

## Installation snippets

- Rust: `html-to-markdown-rs = "3.4"` in Cargo.toml (Rust ≥ 1.85).
- Python: `pip install html-to-markdown` (Python ≥ 3.10).
- TypeScript: `npm install @kreuzberg/html-to-markdown` (Node ≥ 18).
- Go: `go get github.com/kreuzberg-dev/html-to-markdown/packages/go/v3` (Go ≥ 1.26).
- Ruby: `gem 'html-to-markdown', '~> 3.4'` (Ruby ≥ 3.2).
- PHP: `composer require kreuzberg-dev/html-to-markdown` (PHP ≥ 8.2).
- Java: Maven artifact `dev.kreuzberg:html-to-markdown:3.4.0` (Java ≥ 25).
- C#: `dotnet add package KreuzbergDev.HtmlToMarkdown` (.NET 10).
- Elixir: `{:html_to_markdown, "~> 3.4"}` in mix.exs (Elixir ≥ 1.14).
- R: `install.packages("htmltomarkdown")` (R ≥ 4.1).
- WebAssembly: `npm install @kreuzberg/html-to-markdown-wasm`.
- C: shared library + header from GitHub Releases; HTM_H header, `htm_*` symbols.

## Ecosystem

- [Kreuzberg](https://docs.kreuzberg.dev): Document intelligence core — text, tables, metadata from 91+ file formats. Uses html-to-markdown for every HTML input.
- [Kreuzberg Cloud](https://docs.kreuzberg.cloud): Managed SaaS API on top of Kreuzberg.
- [kreuzcrawl](https://docs.kreuzcrawl.kreuzberg.dev): Web crawler for crawl-then-convert pipelines.
- [liter-llm](https://docs.liter-llm.kreuzberg.dev): Universal LLM client.
- [tree-sitter-language-pack](https://docs.tree-sitter-language-pack.kreuzberg.dev): 306 Tree-sitter grammars on demand.
