LangChain data loaders based on Markdown by @untrueaxioms.
Project description
langchain-markitdown
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:
- 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=Truepartitions per-page/worksheet/slide output when MarkItDown provides page data.headers_to_split_on=[("#", "Header 1"), ...]appliesMarkdownHeaderTextSplitterto 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 asdocument_full,document_section,document_page,workbook,worksheet, orpresentation_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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6d6f5bb1822f14e59d78ff690a7c6a93e8af0394da3bd330b6450a1f3d84714
|
|
| MD5 |
67b2bc771627010833d58d576a9252a0
|
|
| BLAKE2b-256 |
78226c2a1131a274ae1217290394148dd4551fd2a11cabe810d4b574f72c7490
|
Provenance
The following attestation bundles were made for langchain_markitdown-1.0.0.tar.gz:
Publisher:
publish.yml on nsasto/langchain-markitdown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_markitdown-1.0.0.tar.gz -
Subject digest:
e6d6f5bb1822f14e59d78ff690a7c6a93e8af0394da3bd330b6450a1f3d84714 - Sigstore transparency entry: 701307447
- Sigstore integration time:
-
Permalink:
nsasto/langchain-markitdown@89cb986621ce3a471731e8cafa74034494405d11 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/nsasto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@89cb986621ce3a471731e8cafa74034494405d11 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_markitdown-1.0.0-py3-none-any.whl.
File metadata
- Download URL: langchain_markitdown-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e35ed721a5aa7eb68e0b227d8766c0132f0681ba4cf8f259db0335f60d7075f2
|
|
| MD5 |
fe5d7bc9f495380d9b21adfce814e024
|
|
| BLAKE2b-256 |
0bc6b7f5e07face92c57c24845e64c3a6ebd0cfa61b713c3c3f88fa0e326fe48
|
Provenance
The following attestation bundles were made for langchain_markitdown-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on nsasto/langchain-markitdown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_markitdown-1.0.0-py3-none-any.whl -
Subject digest:
e35ed721a5aa7eb68e0b227d8766c0132f0681ba4cf8f259db0335f60d7075f2 - Sigstore transparency entry: 701307449
- Sigstore integration time:
-
Permalink:
nsasto/langchain-markitdown@89cb986621ce3a471731e8cafa74034494405d11 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/nsasto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@89cb986621ce3a471731e8cafa74034494405d11 -
Trigger Event:
push
-
Statement type: