Skip to main content

Python

Kreuzberg

Extract text, tables, images, and metadata from 91+ file formats and 248 programming languages including PDF, Office documents, and images. Native Python bindings with async/await support, multiple OCR backends (Tesseract, EasyOCR, PaddleOCR), and extensible plugin system.

Installation

Package Installation

Install via pip:

pip install kreuzberg

For async support and additional features:

pip install kreuzberg[async]

System Requirements

  • Python 3.10+ required
  • Optional: ONNX Runtime version 1.22.x for embeddings support
  • Optional: Tesseract OCR for OCR functionality

Quick Start

Basic Extraction

Extract text, metadata, and structure from any supported document format:

import asyncio
from kreuzberg import extract_file, ExtractionConfig

async def main() -> None:
    config = ExtractionConfig(
        use_cache=True,
        enable_quality_processing=True
    )
    result = await extract_file("document.pdf", config=config)
    print(result.content)

asyncio.run(main())

Common Use Cases

Extract with Custom Configuration

Most use cases benefit from configuration to control extraction behavior:

With OCR (for scanned documents):

import asyncio
from kreuzberg import extract_file

async def main() -> None:
    result = await extract_file("document.pdf")
    print(result.content)

asyncio.run(main())

Table Extraction

import asyncio
from kreuzberg import extract_file

async def main() -> None:
    result = await extract_file("document.pdf")

    content: str = result.content
    tables: int = len(result.tables)
    format_type: str | None = result.metadata.format_type

    print(f"Content length: {len(content)} characters")
    print(f"Tables found: {tables}")
    print(f"Format: {format_type}")

asyncio.run(main())

Processing Multiple Files

import asyncio
from kreuzberg import extract_file, ExtractionConfig, OcrConfig, TesseractConfig

async def main() -> None:
    config = ExtractionConfig(
        force_ocr=True,
        ocr=OcrConfig(
            backend="tesseract",
            language="eng",
            tesseract_config=TesseractConfig(psm=3)
        )
    )
    result = await extract_file("scanned.pdf", config=config)
    print(result.content)
    print(f"Detected Languages: {result.detected_languages}")

asyncio.run(main())

Async Processing

For non-blocking document processing:

import asyncio
from pathlib import Path
from kreuzberg import extract_file

async def main() -> None:
    file_path: Path = Path("document.pdf")

    result = await extract_file(file_path)

    print(f"Content: {result.content}")
    print(f"MIME Type: {result.metadata.format_type}")
    print(f"Tables: {len(result.tables)}")

asyncio.run(main())

Next Steps

Features

Supported File Formats (91+)

91+ file formats across 8 major categories with intelligent format detection and comprehensive metadata extraction.

Office Documents

Category Formats Capabilities
Word Processing .docx, .docm, .dotx, .dotm, .dot, .odt Full text, tables, images, metadata, styles
Spreadsheets .xlsx, .xlsm, .xlsb, .xls, .xla, .xlam, .xltm, .xltx, .xlt, .ods Sheet data, formulas, cell metadata, charts
Presentations .pptx, .pptm, .ppsx, .potx, .potm, .pot, .ppt Slides, speaker notes, images, metadata
PDF .pdf Text, tables, images, metadata, OCR support
eBooks .epub, .fb2 Chapters, metadata, embedded resources
Database .dbf Table data extraction, field type support
Hangul .hwp, .hwpx Korean document format, text extraction

Images (OCR-Enabled)

Category Formats Features
Raster .png, .jpg, .jpeg, .gif, .webp, .bmp, .tiff, .tif OCR, table detection, EXIF metadata, dimensions, color space
Advanced .jp2, .jpx, .jpm, .mj2, .jbig2, .jb2, .pnm, .pbm, .pgm, .ppm OCR via hayro-jpeg2000 (pure Rust decoder), JBIG2 support, table detection, format-specific metadata
Vector .svg DOM parsing, embedded text, graphics metadata

Web & Data

Category Formats Features
Markup .html, .htm, .xhtml, .xml, .svg DOM parsing, metadata (Open Graph, Twitter Card), link extraction
Structured Data .json, .yaml, .yml, .toml, .csv, .tsv Schema detection, nested structures, validation
Text & Markdown .txt, .md, .markdown, .djot, .rst, .org, .rtf CommonMark, GFM, Djot, reStructuredText, Org Mode

Email & Archives

Category Formats Features
Email .eml, .msg Headers, body (HTML/plain), attachments, threading
Archives .zip, .tar, .tgz, .gz, .7z File listing, nested archives, metadata

Academic & Scientific

Category Formats Features
Citations .bib, .biblatex, .ris, .nbib, .enw, .csl Structured parsing: RIS (structured), PubMed/MEDLINE, EndNote XML (structured), BibTeX, CSL JSON
Scientific .tex, .latex, .typst, .jats, .ipynb, .docbook LaTeX, Jupyter notebooks, PubMed JATS
Documentation .opml, .pod, .mdoc, .troff Technical documentation formats

Code Intelligence (248 Languages)

Feature Description
Structure Extraction Functions, classes, methods, structs, interfaces, enums
Import/Export Analysis Module dependencies, re-exports, wildcard imports
Symbol Extraction Variables, constants, type aliases, properties
Docstring Parsing Google, NumPy, Sphinx, JSDoc, RustDoc, and 10+ formats
Diagnostics Parse errors with line/column positions
Syntax-Aware Chunking Split code by semantic boundaries, not arbitrary byte offsets

Powered by tree-sitter-language-pack — documentation.

Complete Format Reference

Key Capabilities

  • Text Extraction - Extract all text content with position and formatting information

  • Metadata Extraction - Retrieve document properties, creation date, author, etc.

  • Table Extraction - Parse tables with structure and cell content preservation

  • Image Extraction - Extract embedded images and render page previews

  • OCR Support - Integrate multiple OCR backends for scanned documents

  • Async/Await - Non-blocking document processing with concurrent operations

  • Plugin System - Extensible post-processing for custom text transformation

  • Embeddings - Generate vector embeddings using ONNX Runtime models

  • Batch Processing - Efficiently process multiple documents in parallel

  • Memory Efficient - Stream large files without loading entirely into memory

  • Language Detection - Detect and support multiple languages in documents

  • Code Intelligence - Extract structure, imports, exports, symbols, and docstrings from 248 programming languages via tree-sitter

  • Configuration - Fine-grained control over extraction behavior

Performance Characteristics

Format Speed Memory Notes
PDF (text) 10-100 MB/s ~50MB per doc Fastest extraction
Office docs 20-200 MB/s ~100MB per doc DOCX, XLSX, PPTX
Images (OCR) 1-5 MB/s Variable Depends on OCR backend
Archives 5-50 MB/s ~200MB per doc ZIP, TAR, etc.
Web formats 50-200 MB/s Streaming HTML, XML, JSON

OCR Support

Kreuzberg supports multiple OCR backends for extracting text from scanned documents and images:

  • Tesseract

  • Easyocr

  • Paddleocr

OCR Configuration Example

import asyncio
from kreuzberg import extract_file

async def main() -> None:
    result = await extract_file("document.pdf")
    print(result.content)

asyncio.run(main())

Async Support

This binding provides full async/await support for non-blocking document processing:

import asyncio
from pathlib import Path
from kreuzberg import extract_file

async def main() -> None:
    file_path: Path = Path("document.pdf")

    result = await extract_file(file_path)

    print(f"Content: {result.content}")
    print(f"MIME Type: {result.metadata.format_type}")
    print(f"Tables: {len(result.tables)}")

asyncio.run(main())

Plugin System

Kreuzberg supports extensible post-processing plugins for custom text transformation and filtering.

For detailed plugin documentation, visit Plugin System Guide.

Embeddings Support

Generate vector embeddings for extracted text using the built-in ONNX Runtime support. Requires ONNX Runtime installation.

Embeddings Guide

Batch Processing

Process multiple documents efficiently:

import asyncio
from kreuzberg import extract_file, ExtractionConfig, OcrConfig, TesseractConfig

async def main() -> None:
    config = ExtractionConfig(
        force_ocr=True,
        ocr=OcrConfig(
            backend="tesseract",
            language="eng",
            tesseract_config=TesseractConfig(psm=3)
        )
    )
    result = await extract_file("scanned.pdf", config=config)
    print(result.content)
    print(f"Detected Languages: {result.detected_languages}")

asyncio.run(main())

Configuration

For advanced configuration options including language detection, table extraction, OCR settings, and more:

Configuration Guide

Documentation

Contributing

Contributions are welcome! See Contributing Guide.

License

MIT License - see LICENSE file for details.

Support

Metadata

Release files for kreuzberg 4.10.3

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

Source distribution (sdist)

Source distribution for kreuzberg 4.10.3
File Size Uploaded
kreuzberg-4.10.3.tar.gz 2.2 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for kreuzberg 4.10.3
File
kreuzberg-4.10.3-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
kreuzberg-4.10.3-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
kreuzberg-4.10.3-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details
kreuzberg-4.10.3-cp310-abi3-macosx_14_0_arm64.whl CPython 3.10 abi3 macOS 14.0+ ARM64 Details

Total release size: 145.0 MB

Release files / kreuzberg-4.10.3.tar.gz

Download URL kreuzberg-4.10.3.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
42bff13de58058589389c0624f2a90b012a7304880f99a11c8a4a7b8feff61d0
BLAKE2b-256 checksum
How to use checksums
e10caf435d39d0a747bd528be9dfa6f3c6a8a9ed73e04672d5725adcc7005bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kreuzberg-4.10.3-cp310-abi3-win_amd64.whl

Download URL kreuzberg-4.10.3-cp310-abi3-win_amd64.whl
Size 36.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
eaa7ca69ca0e4ba893a20c98ad086683d90eb05e425a4894719059eb950b38a0
BLAKE2b-256 checksum
How to use checksums
8429e89549052a38c4f3bbb98eeb90745c6a00e93b4ee923115d30f760ebe96e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kreuzberg-4.10.3-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL kreuzberg-4.10.3-cp310-abi3-manylinux_2_28_x86_64.whl
Size 38.7 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
d64a8be24f1d188653ff6e33ae1c2446d8294082d3e1efe20013288b2a5ed6b8
BLAKE2b-256 checksum
How to use checksums
a67da2c066fdbd3547a7907b22431f2c5fc9149a19ddd35646617990e7f6da6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kreuzberg-4.10.3-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL kreuzberg-4.10.3-cp310-abi3-manylinux_2_28_aarch64.whl
Size 36.4 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
9cc4de332f2fed6f25e421bc6c68bd0fb5a0ec706dc82e571f88217f48977987
BLAKE2b-256 checksum
How to use checksums
fadf1c0915c5f374c09c62d610c84d62c4c9849528e24041dcdf3f32c444e1ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kreuzberg-4.10.3-cp310-abi3-macosx_14_0_arm64.whl

Download URL kreuzberg-4.10.3-cp310-abi3-macosx_14_0_arm64.whl
Size 31.2 MB
Tags CPython 3.10 abi3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
9fa304dd3bd62338c2a62dd59f96e4d33ef330c0b9d504fec3b2290dae10a579
BLAKE2b-256 checksum
How to use checksums
d7f9431c01a254110dd250bf8310c7b0bfd5db84bae5a1f2f90894c616c9a287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release history Release notifications | RSS feed

4.10.4

5 release files

This release

4.10.3 This release

5 release files

4.10.2

5 release files

4.10.1

5 release files

4.10.0

5 release files

4.9.9

5 release files

4.9.7

5 release files

4.9.5

3 release files

4.9.4

5 release files

4.9.3

5 release files

4.9.2

5 release files

4.9.1

5 release files

4.8.6

5 release files

4.8.5

5 release files

4.8.2

5 release files

4.8.0

5 release files

4.7.4

5 release files

4.7.3

5 release files

4.7.2

5 release files

4.7.1

5 release files

4.7.0

5 release files

4.6.3

5 release files

4.6.2

5 release files

4.6.1

5 release files

4.6.0

5 release files

4.5.4

5 release files

4.5.3

5 release files

4.5.2

5 release files

4.5.1

5 release files

4.4.6

5 release files

4.4.5

5 release files

4.4.4

5 release files

4.4.3

5 release files

4.4.2

5 release files

4.4.1

5 release files

4.4.0

5 release files

4.3.8

5 release files

4.3.7

5 release files

4.3.6

5 release files

4.3.5

5 release files

4.3.4

5 release files

4.3.3

5 release files

4.3.2

5 release files

4.3.1

5 release files

4.3.0

5 release files

4.2.9

5 release files

4.2.8

5 release files

4.2.7

5 release files

4.2.6

5 release files

4.2.5

5 release files

4.2.4

5 release files

4.2.3

5 release files

4.2.2

5 release files

4.2.1

5 release files

4.2.0

5 release files

4.1.2

5 release files

4.1.1

5 release files

4.1.0

5 release files

4.0.8

5 release files

4.0.7

5 release files

4.0.6

5 release files

4.0.5

5 release files

4.0.4

5 release files

4.0.3

5 release files

4.0.2

5 release files

4.0.1

5 release files

4.0.0

5 release files

3.22.0

2 release files

3.20.2

2 release files

3.20.1

2 release files

3.20.0

1 release file

3.19.1

1 release file

3.19.0

1 release file

3.18.0

2 release files

3.17.3

2 release files

3.17.2

2 release files

3.17.1

2 release files

3.17.0

2 release files

3.16.0

2 release files

3.15.0

2 release files

3.14.1

2 release files

3.14.0

2 release files

3.13.3

2 release files

3.11.4

2 release files

3.11.3

2 release files

3.11.2

2 release files

3.11.1

2 release files

3.10.1

2 release files

3.10.0

2 release files

3.9.1

2 release files

3.9.0

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.2

2 release files

3.6.1

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.7

2 release files

3.1.6

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 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