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 — correct, readable Markdown from real-world HTML, at competitive speed and near-flat 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. That is a claim about crashing, not speed — deep nesting still costs real time, quadratically; see Scaling: Depth and Width.
  • Configurable pre-processing. Five conversion modes, of which two convert differently: Balanced (the default) and Minimal, which strips to body text and structure for LLM input. The other three are aliases of Balanced — 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 2.17 or newer) mdka@Linux-x64-gnu-<version>.tar.gz
Linux x64 (musl, static) mdka@Linux-x64-musl-<version>.tar.gz
Linux aarch64 (musl, static) mdka@Linux-aarch64-musl-<version>.tar.gz
macOS Apple Silicon mdka@macOS-aarch64-<version>.zip
Windows x64 mdka@Windows-x64-<version>.zip

The glibc archive is built against glibc 2.17, so it runs on Ubuntu 20.04, Debian 11 and RHEL 8 as well as newer systems; the musl archives have no glibc requirement at all.

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. Replace <version> with the release you downloaded (for example 2.6.0).

Linux — use your archive's name (Linux-x64-gnu, Linux-x64-musl or Linux-aarch64-musl) in the first two lines:

tar xzf mdka@Linux-x64-gnu-<version>.tar.gz
cd mdka@Linux-x64-gnu-<version>
echo '<h1>Hello</h1><p><strong>world</strong></p>' | ./mdka
# # Hello
#
# **world**

macOS:

unzip mdka@macOS-aarch64-<version>.zip
cd mdka@macOS-aarch64-<version>
echo '<h1>Hello</h1><p><strong>world</strong></p>' | ./mdka
# # Hello
#
# **world**

Windows (PowerShell):

Expand-Archive mdka@Windows-x64-<version>.zip -DestinationPath .
cd mdka@Windows-x64-<version>
'<h1>Hello</h1><p><strong>world</strong></p>' | .\mdka.exe
# # 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

Prebuilt bindings are published for six platforms: Linux on x64 and arm64 (each with glibc and musl), macOS Apple Silicon, and Windows x64. macOS Intel and Windows ARM are not supported; the installation page lists what does work there.

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()

The Async functions cannot emit deprecation warnings, so an option that has been deprecated is reported only by the synchronous form (htmlToMarkdownWith). See Usage — Node.js.

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 — the default
Minimal LLM input, text extraction — the only mode that converts differently
Strict, Semantic, Preserve Aliases of Balanced; kept for compatibility

Balanced, Strict, Semantic and Preserve produce identical output, and cannot differ. They vary only in the defaults of options that have no effect on Markdown — the format has no syntax for HTML attributes or wrapper elements — so there is no mechanism by which they could diverge. Choosing between them changes nothing. See Conversion Modes for the full explanation.

Tables convert to GFM tables. Column alignment is carried over, | in a cell is escaped, colspan/rowspan are expanded, and a cell holding block content is flattened (paragraphs join with <br>, a list becomes - one<br>- two). Four shapes have no Markdown expression and fall back to one paragraph per cell rather than a broken table: more than one header row, <th> used as each row's first cell, a nested <table>, and a <caption>. No table welds its cells together on either path. 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.7.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.7.0
File Size Uploaded
mdka-2.7.0.tar.gz 1.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for mdka 2.7.0
File
mdka-2.7.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
mdka-2.7.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
mdka-2.7.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
mdka-2.7.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.7.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
mdka-2.7.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 5.2 MB

Release files / mdka-2.7.0.tar.gz

Download URL mdka-2.7.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
1be4d633c6d30c15b66d62f7f69a9b625a1672f1bf9c7ad591d25892a177fc2a
BLAKE2b-256 checksum
How to use checksums
5ed99a7d53a6f749b40b7f0636bdaccbf23e745281ae3385fe9ad0d214031528
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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.7.0-cp310-abi3-win_amd64.whl

Download URL mdka-2.7.0-cp310-abi3-win_amd64.whl
Size 538.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a9cc124b5215876291ab227f193710c9a4fabb422c1a9ab5c8d82ebbb126e250
BLAKE2b-256 checksum
How to use checksums
36d206a2a0300434541f60a1d026de92f1366109577063e08f41e1b5ee088225
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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.7.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL mdka-2.7.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 872.1 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
072942093cfd578ef0e2f37e5b21ae350cf47fd0641e351ff1a5ac9246c045fb
BLAKE2b-256 checksum
How to use checksums
892783cd219f0ce694db632c400d5b06b0e3c46ceed0f17d8e4e3eeaf5309b6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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.7.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL mdka-2.7.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 817.7 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
1f958717a903511a52afe1779832283da602ef3485fed766c8814c37639fb3c8
BLAKE2b-256 checksum
How to use checksums
f957b3fb3edba8055d52ae089f11ea68ee080083941419e1faeab4b5c6178b60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL mdka-2.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 637.1 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
56d5739e0055a19b57de54e01a2ee0ae05d8caeb973f681af881441e893575f8
BLAKE2b-256 checksum
How to use checksums
3bca4dda195eb849848e701a8883d0c1e474f522286dcba617b4446fd19b8ade
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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.7.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mdka-2.7.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 638.2 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
18f68b8f39744fd9d4dfc6274075773248977a7a854f43578275310f6c03c6ec
BLAKE2b-256 checksum
How to use checksums
00538f14bb64d5f6ec0b62313c1f5e162d7897018b7611be245f2e6b57ce2b87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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.7.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL mdka-2.7.0-cp310-abi3-macosx_11_0_arm64.whl
Size 571.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ceb06953d0a9e063423a0253b1d7c69cf8f490a4f9212f45373aa9183be0ec5d
BLAKE2b-256 checksum
How to use checksums
e6d84751ed33579af26dc38fadf6181bc4499c9adba0150089774c50470d7d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","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

This release

2.7.0 This release

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

2.3.0

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