Skip to main content

mdka

A HTML to Markdown converter written in Rust.

crates.io npm pypi License
Documentation Dependency Status CI Executable npm PyPi

logo

mdka balances conversion quality with runtime efficiency — readable output from real-world HTML, without sacrificing speed or memory.
"ka" means "化 (か)" pointing to conversion.


Why mdka?

There are several good HTML-to-Markdown converters in the Rust ecosystem. mdka's specific focus is:

  • Reliable output from diverse HTML sources. It is built on scraper, which uses html5ever — the HTML5 parser from the Servo browser engine. html5ever applies the same parsing algorithm that web browsers use, so it handles malformed tags, deeply nested structures, CMS output, and SPA-rendered DOM without special-casing.
  • Crash resistance. Conversion uses non-recursive DFS throughout. There is no stack overflow, no matter the nesting depth.
  • Configurable pre-processing. Five conversion modes let you tune what gets kept or stripped, from noise-free LLM input to maximum retention. Three of the five currently produce identical output — see Conversion Modes.
  • Multi-language. The same Rust implementation is accessible from Node.js (napi-rs) and Python (PyO3).

Quick Start

Try it from the command line

Download a prebuilt binary (no Rust toolchain needed) from the latest release:

Platform Asset
Linux x64 (glibc) mdka@Linux-x64-gnu-<version>.tar.gz
Linux x64 (musl) mdka@Linux-x64-musl-<version>.tar.gz
Linux aarch64 (musl) mdka@Linux-aarch64-musl-<version>.tar.gz
macOS Apple Silicon mdka@macOS-aarch64-<version>.zip
Windows x64 mdka@Windows-x64-<version>.zip

Other platforms (macOS Intel, Windows ARM, Linux aarch64 glibc) aren't built as binaries — use cargo install mdka-cli below instead.

Extract the archive; it contains one folder holding the mdka binary:

cd mdka@Linux-x64-gnu-<version>  # the folder the archive extracted to

echo '<h1>Hello</h1><p><strong>world</strong></p>' | ./mdka
# # Hello
#
# **world**

Or install via cargo — requires cargo (Rust language) installed:

cargo install mdka-cli

echo '<h1>Hello</h1><p><strong>world</strong></p>' | mdka
# # Hello
#
# **world**
mdka page.html                          # → page.md  (same directory)
mdka --mode minimal --drop-shell -o out/ *.html  # strip nav/header/footer
mdka --help                             # full option list

Add to a Rust project

# Cargo.toml
[dependencies]
mdka = "2"
use mdka::html_to_markdown;

let md = html_to_markdown("<h1>Hello</h1><p><em>world</em></p>");
// "# Hello\n\n*world*\n"

With options:

use mdka::html_to_markdown_with;
use mdka::options::{ConversionMode, ConversionOptions};

let html = "<nav>menu</nav><h1>Hello</h1>";
let mut opts = ConversionOptions::for_mode(ConversionMode::Minimal);
opts.drop_interactive_shell = true;
let md = html_to_markdown_with(html, &opts);
// "# Hello\n"

Add to a Node.js project

npm install mdka
const { htmlToMarkdown, htmlToMarkdownWithAsync } = require('mdka')

const md = htmlToMarkdown('<h1>Hello</h1>')
// "# Hello\n"

async function main() {
  const html = '<nav>menu</nav><h1>Hello</h1>'
  const minimal = await htmlToMarkdownWithAsync(html, {
    mode: 'minimal',
    dropInteractiveShell: true,
  })
  console.log(minimal)
}
main()

Add to a Python project

pip install mdka
import mdka

md = mdka.html_to_markdown('<h1>Hello</h1>')
# "# Hello\n"

html = '<nav>menu</nav><h1>Hello</h1>'
minimal = mdka.html_to_markdown_with(
    html,
    mode=mdka.ConversionMode.Minimal,
    drop_interactive_shell=True,
)

Conversion Modes

Mode Use when
Balanced General use — default
Strict Debugging, diff comparison
Minimal LLM input, text extraction
Semantic SPA content, ARIA-aware pipelines
Preserve Archiving, audit trails

Balanced, Strict and Preserve currently produce identical output. They differ only in the defaults of five fields that have no effect, so choosing between them changes nothing today. They remain distinct API and may diverge again — see Conversion Modes, which explains why in full.

Tables are not yet converted. <table> cell text is emitted without structure or separators, so a table becomes a run of joined text. See Supported Elements for the full list of what is and is not supported.


Learn More

Full documentation is published as GitHub Pages, and its source lives in docs/.

https://nabbisen.github.io/mdka-rs/

Topic Link
Installation /getting-started/installation
Rust Usage & Examples /getting-started/usage-rust
Node.js Usage /getting-started/usage-nodejs
Python Usage /getting-started/usage-python
CLI Reference /getting-started/usage-cli
API Reference /api/index
Conversion Modes /api/modes
ConversionOptions /api/options
Supported Elements /api/elements
Design Philosophy /design/philosophy
Performance Characteristics /design/performance-characteristics
Architecture /design/architecture
Features /design/features
Changelog CHANGELOG.md
Roadmap ROADMAP.md

Open-source, with care

This project is lovingly built and maintained by volunteers.
We hope it helps streamline your work.
Please understand that the project has its own direction — while we welcome feedback, it might not fit every edge case 🌱

Acknowledgements

Depends on scraper (+ html5ever), ego-tree, rayon, thiserror.

Also, napi-rs on binding for Node.js and PyO3's pyo3 / maturin on bindings for Python.

Release files for mdka 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdka 2.3.0
File Size Uploaded
mdka-2.3.0.tar.gz 843.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for mdka 2.3.0
File
mdka-2.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
mdka-2.3.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
mdka-2.3.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
mdka-2.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
mdka-2.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
mdka-2.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 4.7 MB

Release files / mdka-2.3.0.tar.gz

Download URL mdka-2.3.0.tar.gz
Size 843.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fcbc74291c69318de08e3ee0152ade39bdfe1c3dba0b978c0138ecc38dd8fa26
BLAKE2b-256 checksum
How to use checksums
b8ae2088e85cf88354048d33dbaecb5e8408bb1bd0bb6b56bf42e684ad3f1cbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mdka-2.3.0-cp310-abi3-win_amd64.whl

Download URL mdka-2.3.0-cp310-abi3-win_amd64.whl
Size 505.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
84264f236caa9438d12b32714ad29dcf964332bbeff9a512f2b2bbf569a02490
BLAKE2b-256 checksum
How to use checksums
44041542c378f5ab3edfd7c3a6327a8f73a87f8c1ae566c7be22a698e8aa85c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mdka-2.3.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL mdka-2.3.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 839.7 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
29382d1e80a0bc35808e46872c5efb747dbba40593e755afc42771a1d3198ca2
BLAKE2b-256 checksum
How to use checksums
3deac527b071b4646b55b4e37dea52175ef32d14e14388ec2ebd0463dfab7c4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mdka-2.3.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL mdka-2.3.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 789.5 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
ccf832918cad1ba8898a3ff4f47cdefe3e5f2fc5a699e9d9ea6031a0d8f724d0
BLAKE2b-256 checksum
How to use checksums
3a648ecee270b5e70d3d741dd0b98477a901029c377b2acb06f9501c6d2999fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mdka-2.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL mdka-2.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 606.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
44613aa1d15153d94e76a868c00a1bd8cc9eb5e486ed88645babfeac59a2c5a7
BLAKE2b-256 checksum
How to use checksums
f0cb0527e22b9d54fc382f8ec37e54f11bdbfbe4ff3e2681b7cab74537d1ae3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mdka-2.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mdka-2.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 609.9 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5ca109a4f368f4b9709d29472f7338b99dbb4eea39f4d7d02fda51dd9e56a4e7
BLAKE2b-256 checksum
How to use checksums
47311fc5b32902364a5bbe26c4c50a48e5a9bdeef941a886257971ec15e57176
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mdka-2.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL mdka-2.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 541.4 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e9d2eb33634c0ace5ae0a5103625703bf1dfe893aa4cfc7befe1d8af4caff694
BLAKE2b-256 checksum
How to use checksums
f38ece322156edc86f8d2ef813c85fc06800b9bc7a5341d7e87ae22348e94a47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

2.7.0

7 release files

2.6.0

7 release files

2.5.1

7 release files

2.5.0

7 release files

2.4.2

7 release files

2.4.1

7 release files

2.4.0

7 release files

This release

2.3.0 This release

7 release files

2.2.3

47 release files

2.2.2

47 release files

2.2.0

47 release files

2.1.8

47 release files

2.1.5

48 release files

2.1.4

48 release files

2.1.1

48 release files

2.1.0

48 release files

2.0.3

48 release files

2.0.2

48 release files

1.6.8

40 release files

1.6.7

40 release files

1.6.5

40 release files

1.6.4

40 release files

1.6.3

40 release files

1.6.2

40 release files

1.6.1

40 release files

1.6.0

40 release files

1.5.0

49 release files

1.4.7

48 release files

1.4.6

48 release files

1.4.5

48 release files

1.4.4

48 release files

1.4.0

44 release files

1.3.3

44 release files

1.3.2

44 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page