chunk-engine
One Rust engine · 3 languages · 36 formats

One chunking engine.
Python, JavaScript, Rust.

A fast, high-fidelity document chunking engine for RAG. 36 formats, one Rust core — with byte-identical bindings for Python, JavaScript, and Rust.

pip install py-chunks

py-chunks · js-chunks · rs-chunks

from py_chunks import get_chunks

# One API. Every format. Rust underneath.
chunks = get_chunks("report.pdf", mode="semantic")

for chunk in chunks:
    print(chunk["content_type"], "->", chunk["content"][:48])

# heading          -> Q3 Financial Summary
# semantic         -> Revenue grew 18% quarter-over-quarter, driven...
# table            -> | Region | Revenue | YoY |

Performance

Milliseconds, not seconds

A Rust core does the parsing and segmentation. Measured over 446 real files against its peers, Docling and Unstructured — see the full benchmark.

Documents per second (pooled)

files / sec · higher is better
chunk-engine1,980
docling36
unstructured9

Time per document (pooled)

ms / file · lower is better
chunk-engine0.51
docling27.87
unstructured112.77

Measured over 446 files on Apple M1 Max (py-chunks 0.5.0). See the benchmarks page for full methodology.

Why chunking

Chunking is the hidden lever in retrieval quality

Retrieval is only as good as its chunks. Bad boundaries bury the answer; slow, dependency-heavy splitters bottleneck ingestion. chunk-engine fixes both.

Naive fixed-size splitting

…the Q3 revenue figure was $6.8M, representing a 21% incr
ease over the prior year. Meanwhile operating margin held ▓
| Region | Revenue | ← table split across two chunks
| EMEA | $4.2M | +12% | AMER | $6.8M…

Sentences cut mid-word, tables severed, headings orphaned — the embedding model never sees a coherent unit, so retrieval misses.

chunk-engine — structure-aware

heading · "Q3 Financial Summary"
semantic · Revenue grew 18% QoQ, driven by enterprise expansion…
table · | Region | Revenue | YoY | (kept whole)
bullet_list · North America +21%, EMEA +12%, APAC accelerating

Each chunk is a complete semantic unit with a typed content_type — headings, tables, and lists stay intact, so retrieval lands on the answer.

Formats

36 formats, one engine

Office, PDF, web, plain-text, data, email, eBooks, and notebooks — grouped by family, each with an honest availability badge.

Stable New

Word

5

OOXML + legacy binary Word

.docx.doc.docm.dotx.dotm

PowerPoint

6

OOXML + legacy binary PowerPoint

.pptx.ppt.potx.potm.ppsx.ppsm

Spreadsheets

7

Excel + OpenDocument sheets

.xlsx.xls.xlsm.xlsb.xltx.xltm.ods

PDF

1

Text + page-scoped images

.pdf

Web & Markup

4

Markup and rich text

.html.htm.md.rtf

OpenDocument

2

LibreOffice / OpenOffice documents

.odt.odp

Plain & Data

6

Text and structured data

.txt.csv.tsv.json.jsonl.ndjson

Email

3

Outlook + MIME email

.msg.eml.mbox

eBooks & Notebooks

2

EPUB and Jupyter

.epub.ipynb

New formats live in the library source and latest builds; the current published wheel documents a subset. Upgrade with pip install -U py-chunks to pick up the newest formats.

See it

Watch a document become chunks

A sample document on the left; colored chunk blocks on the right, keyed by content type. Toggle the mode and watch the blocks regroup.

mode=
report.pdf
HQ3 Financial Summary
Revenue grew 18% quarter-over-quarter, driven by expansion in enterprise accounts.
Operating margin held steady at 22% despite increased R&D investment.
HRegional Breakdown
| Region | Revenue | YoY | | EMEA | $4.2M | +12% | | AMER | $6.8M | +21% |
• North America led growth at +21% • EMEA steady at +12% • APAC accelerating into Q4
HIngest Example
</>chunks = get_chunks("q3.pdf", mode="semantic")
chunks8 chunks
heading

Q3 Financial Summary

plain_paragraph

Revenue grew 18%…

plain_paragraph

Operating margin…

heading

Regional Breakdown

table

Region / Revenue table

bullet_list

Growth bullet list

heading

Ingest Example

code_block

get_chunks(…) call

One chunk per element — each heading, paragraph, table, and list stands alone.

headingplain_paragraphtablebullet_listcode_block

One engine, three languages

Same chunks, everywhere

Pick the SDK that fits your stack — Python, JavaScript, or Rust. They wrap the same engine and produce byte-identical output.

py-chunks

Native extension via PyO3.

$ pip install py-chunks
PyPI
js-chunks

WASM core — Node, Bun, Deno, and browsers.

$ npm install js-chunks
npm
rs-chunks

The reference engine — pure Rust.

$ cargo add rs-chunks
crates.io

Byte-identical, verified

All three SDKs wrap the same Rust engine, so they emit exactly the same chunks. Parity is checked over every fixture × every mode — the only differences trace to the reference engine's own non-determinism.

pip install py-chunks
  • 2204 / 2214 chunk comparisons byte-identical (99.5%)
  • 1056 / 1056 image extractions identical
  • 273 / 273 markdown conversions identical

Modes

Seven ways to chunk a document

default, structural, section, semantic, sliding_window, sentence, page_aware — plus row / table / sheet for spreadsheets.

default

Element-level chunks — one per paragraph or heading.

Best for: Fine-grained, element-level control.

structural

Index every paragraph and heading individually.

Best for: Fine-grained retrieval over document structure.

sectionrecommended

Keep all content under a heading together in one chunk.

Best for: Section-level search / document indexes.

semanticrecommended

Group semantically coherent passages together.

Best for: Feeding an LLM or embedding model.

sliding_window

Overlapping windows with configurable size and overlap.

Best for: Dense retrieval / sliding-context inference.

sentence

Enforce a fixed number of sentences per chunk.

Best for: Tight token budgets.

page_aware

Preserve the document's original page layout.

Best for: Page-referenced citations.

Spreadsheets (XLSX / XLS / ODS / CSV) add dedicated modes:

rowtablesheet

Quick start

Chunk your first document

One call. Switch the language tab to see the exact API for your SDK.

from py_chunks import get_chunks, stream_chunks, get_markdown

# Batch — works for every supported format
chunks = get_chunks("document.pdf")
chunks = get_chunks("notes.md",  mode="semantic")
chunks = get_chunks("deck.pptx", mode="sliding_window", window_size=3, overlap=1)

for chunk in chunks:
    print(chunk["content"], chunk["content_type"], chunk["metadata"])

# Streaming — constant memory over huge files
for chunk in stream_chunks("large.pdf", mode="section"):
    handle(chunk)

# Markdown conversion
md = get_markdown("report.docx")

Start chunking in one line

Install for your language, point it at a file, get clean chunks back. No services, no config, no heavy dependency tree.

pip install py-chunks