开源工具
dev.to ·
@ArshTechPro
Docling:为 AI 应用把杂乱文档转为干净数据
Docling 是一个开源 Python 库,用于将 PDF、Word、幻灯片、扫描图像等文档转换为 Markdown、HTML 或 JSON 等结构化输出,以解决基础 PDF 转文本工具中表格错乱、双栏阅读顺序错误、页眉混入正文等问题。它由 IBM Research Zurich 发起,现由 LF AI & Data Foundation 托管,采用 MIT 许可,支持 PDF、DOCX、PPTX、XLSX、HTML、EPUB、图像、LaTeX、邮件等输入格式,并尝试识别版面与阅读顺序、重建表格、识别代码块、公式和图像。
AI推荐理由 介绍 IBM Research Zurich 发起、现由 LF AI & Data Foundation 托管的开源文档解析库 Docling,支持 PDF、DOCX、PPTX 等格式并输出 Markdown/HTML/JSON,能识别版面、阅读顺序、表格、代码块与公式,对 RAG 数据清洗有实际用途。摘要提及 GitHub 星数,但星数不能证明工具实际效果,且正文被截断。
74
正文
The problem
If you've built anything with LLMs, you've hit this wall: your data lives in PDFs, Word files, slide decks, and scanned images. You need clean text to feed a model or a RAG pipeline. Basic PDF-to-text tools give you a jumbled mess: tables collapse into random lines, two-column layouts get read in the wrong order, and headers mix with body text.
Docling is an open-source Python library built to solve exactly that.
What Docling is
Docling reads documents and converts them into structured output such as Markdown, HTML, or JSON. It was started by IBM Research Zurich, is now hosted by the LF AI & Data Foundation, and is MIT licensed. It has over 66k stars on GitHub, so it's far from a side project.
What sets it apart from a plain text extractor is that it tries to understand the page. It detects layout and reading order, rebuilds tables, and recognizes code blocks, formulas, and images.
What it supports
Input formats include PDF, DOCX, PPTX, XLSX, HTML, EPUB, images, LaTeX, email files, and even audio and video (transcribed with speech recognition models). Scanned PDFs are handled with OCR.
Everything is converted into one internal format called DoclingDocument, which you can then export as Markdown, HTML, or lossless JSON. That means your downstream code deals with one structure no matter what the input was.
Getting started
You need Python 3.10 or newer.
pip install docling
Enter fullscreen mode
Exit fullscreen mode
Convert a document from the command line:
docling https://arxiv.org/pdf/2206.01062
Enter fullscreen mode
Exit fullscreen mode
This writes a .md file to your current directory.
Or use it from Python:
from docling.document_converter import DocumentConverter
converter = DocumentConverter()
result = converter.convert("https://arxiv.org/pdf/2408.09869")
print(result.document.export_to_markdown())
Enter fullscreen mode
Exit fullscreen mode
That's it. Local file paths work the same way as URLs.
Where it fits in your stack
Docling has ready-made integrations with LangChain, LlamaIndex, CrewAI, and Haystack, so you can drop it into an existing RAG pipeline as the document loader. It also ships an MCP server for connecting it to AI agents, and an API server (docling-serve) if you'd rather run it as a service than import it as a library.
It runs fully locally, which matters if you're handling sensitive documents or working in an air-gapped environment. No data has to leave your machine.
Is it worth a try?
Yes, if any of these describe you:
You're building a RAG system or chatbot over real-world documents.
You have PDFs with tables that other tools mangle.
You need to process many file types without writing a separate parser for each.
You can't send documents to a third-party API.
A few honest caveats. Docling uses machine learning models for layout and table detection, so the install is heavier than a lightweight library like pypdf, and models are downloaded on first run. Processing large PDF batches on CPU can be slow, and a GPU helps a lot. If all you need is raw text from simple, single-column PDFs, a lighter tool will do the job with less overhead.
Links
GitHub: https://github.com/docling-project/docling