Stop Copy-Pasting From PDFs: DocStrange Turns Messy Documents Into Clean Data for Your LLMs
You know the drill. You've got a stack of PDFs, some scanned images, maybe a few PowerPoint decks, and you need to get that text into something your language model can actually use. The copy-paste dance is miserable—tables get mangled, formatting collapses, and scanned documents are a wall of OCR gibberish. It's a pain point that eats hours of your week. That's exactly the problem DocStrange is built to solve. It's an open-source Python library that takes your messy documents and outputs clean, structured data ready for RAG pipelines and AI workflows.
What It Does
DocStrange is a document conversion library from the folks at Nanonets. It ingests a wide variety of formats—PDF, DOCX, PPTX, XLSX, and images—and outputs them as Markdown, JSON, CSV, or HTML. The core goal is producing what they call "LLM-optimized Markdown," meaning the output is stripped of page artifacts and formatted in a way that models can parse without getting confused by headers, footers, or page numbers.
Under the hood, it's a pipeline of OCR and layout detection models. The recent upgrade bumped the core model to 7B parameters, which the maintainers say delivers higher accuracy and deeper understanding of complex documents. For images and scans, it handles OCR directly, so you don't need a separate preprocessing step for old, text-based images.
There's also a structured extraction mode. If you give it a JSON schema or a list of specific fields you want pulled out, it'll return structured JSON that fits your requirements. The library requires Python >=3.8 and runs on Windows, macOS, and Linux.
Why It's Cool
DocStrange's approach to deployment is what makes it stand out. You get two distinct processing modes that cover opposite ends of the privacy spectrum:
-
Free Cloud Processing: You can process up to 10,000 documents per month without paying anything. No complex setup, no local GPU required—you just hit their API and get results back. For quick experiments or low-volume work, that's a generous free tier that removes the friction of testing.
-
100% Local Processing: If your data is sensitive or you just don't want it leaving your machine, you can run everything locally. There's a
gpumode that keeps all processing on your hardware. It works on CPU too, so you're not locked out if you don't have a beefy card sitting in your workstation.
Beyond the core conversion, there are a few details that show real developer consideration. The built-in, local web UI gives you a drag-and-drop interface that works fully offline—handy for non-technical teammates or quick visual checks. And there's an MCP server integration for Claude Desktop, so you can navigate and query documents conversationally if you're live in that ecosystem.
The table handling deserves a specific mention. Anyone who's tried to feed a complex spreadsheet or a multi-column PDF table into an LLM knows that tables are where document parsers go to die. DocStrange explicitly focuses on formatting tables into clean Markdown, which is a huge win for keeping structured data intact through the conversion process.
How to Try It
Getting started is straightforward. You can install it directly from PyPI:
pip install docstrange
From there, you've got options. If you want the zero-setup path, head over to their hosted demo at docstrange.nanonets.com to see the conversion in action in your browser. For local work, you can leverage the free cloud API for instant processing, or switch to local mode with gpu if you want everything to stay on your machine.
The repository's README points to the issues page for bug reports and feature requests, and the discussions forum is the place for questions and help. If you run into edge cases with weird document layouts, that's likely where you'll find answers or can contribute your own findings.
# Basic usage pattern (conceptual—check the README for full API details)
from docstrange import DocStrange
converter = DocStrange(mode="cloud") # or mode="gpu" for local
result = converter.convert("path/to/your/document.pdf")
print(result.markdown) # Clean, LLM-ready output
Final Thoughts
DocStrange is a practical tool for a very real problem. If you're building RAG applications, preprocessing document corpora, or just tired of fighting with PDF text extraction, it's worth a look. The dual cloud/local model is a thoughtful touch—you're not forced into a privacy trade-off just to try it out. The 7B model upgrade suggests the maintainers are actively investing in accuracy, which is the make-or-break metric for this kind of tool. It's not magic, and complex layouts will still throw curveballs, but for the common case of getting documents into LLM-ready shape, it's a solid addition to your toolkit. If you're doing serious document work, this could save you a weekend of wrestling with parsing libraries.
Follow @githubprojects for more developer tools and open source projects.