Skip to main content

LangChain data loaders based on Markdown by @untrueaxioms.

Project description

langchain-markitdown

Build License PyPI version Contributors

Markitdown LangChain Integration

This project provides document loaders that seamlessly integrate the Markitdown library with LangChain. Markitdown excels at converting various document types (DOCX, PPTX, XLSX, and more) into Markdown format. These loaders empower you to effortlessly load, process, and analyze these documents within your LangChain pipelines.

MarkItDown is a lightweight Python utility designed for converting diverse file formats into Markdown, optimized for use with Large Language Models (LLMs) and related text analysis workflows. It shares similarities with textract but distinguishes itself by prioritizing the preservation of crucial document structure and content as Markdown. This includes headings, lists, tables, links, and more. While the output is generally readable, its primary purpose is to be consumed by text analysis tools, rather than serving as a high-fidelity document conversion solution for human readers.

Explore the MarkItDown project on GitHub: https://github.com/microsoft/markitdown

Currently, MarkItDown supports:

  • PDF
  • PowerPoint
  • Word
  • Excel
  • Images (EXIF metadata and OCR)
  • Audio (EXIF metadata and speech transcription)
  • HTML
  • Text-based formats (CSV, JSON, XML)
  • ZIP files (iterates over contents)
  • YouTube URLs
  • EPUBs
  • ...and many more!

While this project borrows liberally from the amazing LangChain and Markitdown projects, it is not affiliated with either in any way.

Installation

Install the package using pip:

pip install langchain-markitdown

Usage & Features

The loaders expose a consistent interface that mirrors LangChain's built-in ones but leverage the MarkItDown converters under the hood. Highlights:

  • Centralized metadata handling: every loader emits success, conversion_success, content_type, and MarkItDown's native metadata (page count, attachments, output type, etc.).
  • Flexible splitting modes:
    • split_by_page=True partitions per-page/worksheet/slide output when MarkItDown provides page data.
    • headers_to_split_on=[("#", "Header 1"), ...] applies MarkdownHeaderTextSplitter to create logical sections from the converted Markdown.
  • Loader-specific metadata enrichment, e.g. DOCX core properties, XLSX workbook metadata via openpyxl, PPTX slide/image counts, and more.

Usage

Specific Examples

DOCX

from langchain_markitdown import DocxLoader, PptxLoader, XlsxLoader

loader = DocxLoader("path/to/your/document.docx")
documents = loader.load()

# Split by pages or headers when needed
documents_by_page = DocxLoader(
    "path/to/your/document.docx",
    split_by_page=True,
).load()

documents_by_headers = loader.load(
    headers_to_split_on=[("#", "H1"), ("##", "H2")],
)

PPTX

from langchain_markitdown import PptxLoader

loader = PptxLoader("path/to/your/presentation.pptx")
documents = loader.load()

XLSX

from langchain_markitdown import XlsxLoader

loader = XlsxLoader("path/to/your/spreadsheet.xlsx")
documents = loader.load()

Metadata

The Document objects returned by the loaders include the following metadata:

  • source: The path to the source file.
  • file_name: The name of the source file.
  • file_size: The size of the source file in bytes.
  • success / conversion_success: Boolean flags that include failure details when conversion fails.
  • content_type: Semantic tags such as document_full, document_section, document_page, workbook, worksheet, or presentation_slide.
  • page_number / worksheet: When splitting by page/worksheet.
  • markitdown_metadata: Raw metadata surfaced by MarkItDown (attachments, page counts, conversion format, etc.).
  • Loader-specific enrichments:
    • DOCX: author/title/subject/keywords/category/revision timestamps.
    • XLSX: workbook properties (author, title, subject, description, keywords, category).
    • PPTX: slide counts plus counts for images, tables, charts, and text boxes.

When header-based splitting is enabled, LangChain's header metadata is injected automatically.

Development & Testing

Install dependencies (and the package itself in editable mode) before running tests:

python -m pip install -r requirements.txt
python -m pip install -e .
pytest

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

MIT License

Trademarks

Markitdown, and so this project by extension, may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_markitdown-1.0.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_markitdown-1.0.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_markitdown-1.0.0.tar.gz.

File metadata

  • Download URL: langchain_markitdown-1.0.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_markitdown-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e6d6f5bb1822f14e59d78ff690a7c6a93e8af0394da3bd330b6450a1f3d84714
MD5 67b2bc771627010833d58d576a9252a0
BLAKE2b-256 78226c2a1131a274ae1217290394148dd4551fd2a11cabe810d4b574f72c7490

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_markitdown-1.0.0.tar.gz:

Publisher: publish.yml on nsasto/langchain-markitdown

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_markitdown-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_markitdown-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e35ed721a5aa7eb68e0b227d8766c0132f0681ba4cf8f259db0335f60d7075f2
MD5 fe5d7bc9f495380d9b21adfce814e024
BLAKE2b-256 0bc6b7f5e07face92c57c24845e64c3a6ebd0cfa61b713c3c3f88fa0e326fe48

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_markitdown-1.0.0-py3-none-any.whl:

Publisher: publish.yml on nsasto/langchain-markitdown

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page