If you've tried chatting with your own PDFs in a local AI app, you've probably seen it get tables wrong, mix up columns or miss text in scanned pages. Much of that happens before the language model is involved: the PDF has to be turned into clean text first, and a plain text dump loses headings, tables and reading order. Docling is a free, open-source tool that converts PDFs and many other documents into Markdown or JSON that local AI tools can use, and it runs entirely on your own PC. This guide is based on Docling's official GitHub README, installation guide, CLI reference and GPU guide.
What Docling is
Docling was started by the AI for knowledge team at IBM Research Zurich and is now hosted by the LF AI & Data Foundation. Its codebase is under the MIT licence; the README says the models it downloads carry their own licences, so check those if you're using it commercially.
According to the README, Docling understands page layout, reading order, table structure, code and formulas in PDFs, has OCR for scanned PDFs and images, and can run locally for sensitive data and air-gapped machines. As well as PDF it reads Word, PowerPoint and Excel files, HTML, EPUB, images, LaTeX and more, and newer releases add audio and video (transcribed with speech recognition models). It exports to Markdown, HTML, plain text and a lossless JSON format, among others.
For local AI, that means you can turn a folder of manuals, payslips or research papers into Markdown files that drop straight into Open WebUI knowledge bases, AnythingLLM or your own RAG scripts.
What you need
Python 3.10 or newer. The README says Python 3.9 support was dropped in Docling 2.70.0.
Windows, macOS or Linux, on x86_64 or arm64.
A GPU is optional. Docling's models run on PyTorch and the CLI's --device option accepts auto, cpu, cuda, mps and xpu. A CPU is fine for occasional documents; an Nvidia card helps with large batches.
Disk space for models. Docling relies on its own layout, table and OCR models; the docling-tools models download command fetches them in advance and stores them in $HOME/.cache/docling/models by default.
Step 1: Install Docling
Open a terminal (PowerShell on Windows), ideally inside a Python virtual environment so Docling's dependencies don't clash with other AI tools, then run:
pip install docling
If you use uv, the equivalent is uv add docling. On a Linux machine without a GPU, the installation guide suggests pulling the smaller CPU-only build of PyTorch instead:
pip install docling --extra-index-url https://download.pytorch.org/whl/cpu
If you want GPU acceleration on Windows with an Nvidia card, make sure you have a CUDA build of PyTorch; our guide to installing PyTorch with CUDA on Windows covers that, and this fix helps if PyTorch can't see the GPU.
Step 2: Convert your first PDF
The simplest command takes a local file or a URL:
docling convert report.pdf
The README's quick-start also shows the shorter form docling report.pdf. By default Docling writes a Markdown (.md) file to the current folder. To choose where files go, add --output:
docling convert report.pdf --output C:\Docs\converted
You can also point it at a whole folder of documents rather than a single file.
The --to option controls what Docling writes, and you can repeat it to get several formats at once. The most useful for local AI are:
Option | What you get | Use it for |
|---|
--to md
| Markdown (the default) | Uploading to Open WebUI, AnythingLLM or LM Studio document chat |
--to json
| Docling's lossless JSON | Your own scripts, keeping layout and page positions |
--to text
| Plain text | Tools that don't understand Markdown |
--to chunks
| Ready-made chunks | Feeding your own embedding pipeline directly |
The chunks option uses a hybrid chunker by default with the sentence-transformers/all-MiniLM-L6-v2 tokenizer, and --chunks-max-tokens caps each chunk's size. If you plan to use a different embedding model, set --chunks-tokenizer to match it; our best local embedding models guide lists good options.
For images, --image-export-mode chooses between embedded (images inside the file as base64, the default), referenced (separate PNG files) and placeholder (just a marker where an image was). For RAG, placeholder keeps Markdown files much smaller because there's no image data to index.
Step 4: Handle scanned documents and OCR
OCR is on by default (--ocr), so Docling reads text from images and scanned pages. Two options are worth knowing:
--force-ocr replaces any existing text layer with fresh OCR across the whole document. Use it when a PDF has a broken or garbled text layer, which is common with old scans.
--ocr-lang sets the OCR language, for example --ocr-lang en,de. The CLI reference says the default treats this as the OCR engine's own language tag; prefix a standard language tag with iso: if you want Docling to translate it.
The --ocr-engine option chooses between engines such as EasyOCR, RapidOCR and Tesseract, with auto as the default. If you're converting digital PDFs that already contain proper text, --no-ocr skips OCR entirely.
Step 5: Get tables and page ranges right
Table extraction is on by default and the --table-mode option defaults to accurate; switch to --table-mode fast if you have lots of documents and can accept rougher tables. To convert only part of a long manual, use --page-range 1-20 (page numbers start at 1).
Step 6: Speed it up with your GPU
Docling picks a device automatically, but you can force your graphics card with --device cuda. The CLI also has a --page-batch-size option (default 4 pages). Docling's GPU guide explains that larger batches let the layout model run in GPU batch mode, and its Python example raises the OCR and layout batch sizes from the default 4 to 64. Bigger batches use more VRAM, so if you hit out-of-memory errors, lower them again; our guide to checking VRAM use in Windows shows how to watch it.
For OCR on the GPU, the guide says GPU support depends on the OCR engine. RapidOCR supports GPU acceleration through its Torch and ONNX Runtime back ends, and on Windows and Linux you can install the GPU-enabled ONNX Runtime extra with pip install "docling[onnxruntime]".
Optional: Use a vision model instead
Docling also has a VLM pipeline that reads each page with a small vision-language model, IBM's GraniteDocling, instead of the standard layout and OCR models:
docling --vlm-model granite_docling report.pdf
The GPU guide recommends running the VLM through a local inference server for the best GPU use. It lists vLLM (Linux only), LM Studio and Ollama as OpenAI-compatible servers Docling can talk to, and shows ibm-granite/granite-docling-258M served with vLLM. For most people the standard pipeline is the place to start; try the VLM route on documents the standard pipeline struggles with.
Using Docling from Python
If you're building your own RAG script, the README's recommended route is Python:
from docling.document_converter import DocumentConverter
converter = DocumentConverter()
result = converter.convert("report.pdf")
print(result.document.export_to_markdown())
Docling also lists ready-made integrations with LangChain, LlamaIndex, Haystack and Crew AI, an MCP server for AI agents, and an API server called docling-serve. Open WebUI's documentation lists Docling as one of its built-in document extraction engines, so you can use it there without converting files by hand.
Common problems
"docling" isn't recognised: the Python Scripts folder isn't on your PATH, or you installed into a different virtual environment. Activate the environment you installed it in and try again.
Garbled text from a scan: re-run with --force-ocr, and set --ocr-lang if the document isn't in English.
Running out of VRAM: lower --page-batch-size, or use --device cpu for that document.
Intel Mac errors: the installation guide says newer PyTorch versions no longer provide wheels for Intel Macs, and suggests pip install "docling[mac_intel]".
If you're still weighing up which converter to use, see our comparison of Docling vs Marker.