Skip to content

Repository files navigation

ComPDF Solutions

English | 繁體中文 | 简体中文

DocSlight - An Open-source Document Parser & Document Data Extraction Engine

Part of the KDAN ecosystem, DocSlight offers document parsing, OCR, and data extraction that turn PDFs, scans, images, and Office files into structured outputs for RAG pipelines, AI agents, and enterprise document automation.

  • If you find DocSlight useful, please consider giving us a ⭐ Star on GitHub. It helps us grow and improve.
  • Got questions or ideas? Join the conversation in our Discussions.

LicensePythonGitHub StarsPyPIPRs Welcome

Quick StartProduct EditionsUsageBenchmarkCloud API →Documentation

Why DocSlight?

Unlike traditional OCR tools, DocSlight combines AI-powered document parsing, OCR for 80+ languages, and structured data extraction into a single open-source platform. You can deploy it locally or use it via cloud API with higher accuracy.

Key Advantages

  • Open-source document data extraction engine with no vendor lock-in
  • OCR for 80+ languages with multilingual auto-detection
  • Structured field extraction with bounding-box traceability
  • Markdown / JSON output for downstream processing
  • Web UI + CLI + Python SDK
  • Local deployment or Cloud API
  • Built for RAG, AI Agents, and enterprise document workflows

Perfect For

  • RAG pipelines and knowledge base construction
  • Invoice processing and document information extraction
  • Contract analysis and clause parsing
  • AI copilots and AI agent tool integration
  • Enterprise document automation and intelligent document processing (IDP)

Whether you're building a personal RAG project or a large-scale enterprise document automation system, DocSlight provides a scalable foundation for document understanding.

DocSlight Demo

Quick Start

Cloud Mode (Higher accuracy, free quota available)

# 1. Install
pip install docslight
# 2. Set your API keyexport COMPDF_API_KEY="your_public_key"# Get one at https://compdf.com# 3. Parse with the cloud engine
docslight parse invoice.pdf --mode cloud --output invoice.md

Get the API Key:Log in to the ComPDF Console. On the API Key page, create or copy your publicKey.

get-license-en

Local Mode (Free, no registration required)

# 1. Install
pip install docslight
# 2. Parse a document
docslight parse invoice.pdf --mode local --output invoice.md
# 3. Get structured results
ls invoice.zip

Web UI (Browser)

git clone https://github.com/ComPDF/docslight.git
cd docslight
docker compose -f docker/docker-compose.yml up
# Open http://localhost:3022 and drag & drop files

All features above come with ComPDF — check them out here.

Product Editions

Need workflow automation, RBAC, audit logs, private deployment, or dedicated support? Explore Enterprise:https://www.compdf.com/ai/docslight

FeatureDocSlight Lite (Local)DocSlight-Lite (Cloud)DocSlight Enterprise (SaaS)DocSlight Enterprise (Self-hosted Deployment)
Upload Files from Local
Upload Files from Cloud
Upload Files from DMS
Upload Files from Scanner
PDF Parsing
Image Parsing
Word / PPT / Excel Parsing
Markdown Output
JSON Output
PDF ExtractionLocal LLM Required
Image ExtractionLocal LLM Required
Word / PPT / Excel ExtractionLocal LLM Required
Legacy Office Formats for Parsing and Extraction (.doc/.ppt/.xls)
Batch Processing
Auto Classification
Human Review Workflow
Complex Layout AnalysisBasicAdvancedAdvancedAdvanced
OCR OptimizationBasicAdvancedAdvancedAdvanced
Result Traceability
Result Post-Processing
Intelligent Result Review
Custom Rule-Based Alerts
Webhook Integration
API ManagementLimited
Knowledge Base Integration
Audit Logs
RBAC
Tenant Support
Self-hosted DeploymentLocal Only
Dedicated GPUOptional

Input/Output Format Matrix

Input typeExtensionsCloud parseLocal parseCloud extractLocal extractParse outputsExtract outputsNotes
PDF.pdf✅ Requires local LLMMarkdown, JSON, standard JSON, ZIPJSONLocal PDF parsing uses raster/OCR processing.
Images.png, .jpg, .jpeg, .tif, .tiff, .bmp, .webp✅ Requires local LLMMarkdown, JSON, standard JSON, ZIPJSONLocal image parsing treats each image as one page.
Word.docx✅ Requires local LLMMarkdown, JSON, standard JSON, ZIPJSONLocal legacy .doc is not supported.
PowerPoint.pptx✅ Requires local LLMMarkdown, JSON, standard JSON, ZIPJSONLocal legacy .ppt is not supported.
Excel.xlsx✅ Requires local LLMMarkdown, JSON, standard JSON, ZIPJSONLocal legacy .xls is not supported.
Legacy Office.doc, .ppt, .xlsCloud API dependentCloud API dependentCloud result formatsJSONConvert to .docx, .pptx, or .xlsx before local processing.

docslight convert-parse-json accepts a local parse JSON object and writes the standard parse JSON schema. It does not process original document files.

Installation And First Run

DocSlight supports Python 3.10 through 3.13.

pip install "docslight"

Cloud mode requires network access and a valid ComPDF Cloud API key. Local mode runs on CPU by default; OCR and LLM latency depends on document size, hardware, and the selected model.

Use Cases

  • RAG Pipeline — Parse documents -> embed vectors -> query with an LLM
  • Invoice Processing — Extract invoice numbers, dates, totals, and line items
  • Contract Analysis — Parse clauses, parties, and dates with bounding-box traceability
  • Document Digitization — Batch convert scanned archives into searchable text
  • AI Agent Integration — Provide MCP-based document reading for Claude / ChatGPT

Runnable example code is available in examples/:

Usage

Python SDK

fromdocslightimportParser# Local mode — open-source OCR and document parsingparser=Parser(mode="local")
result=parser.parse("contract.pdf")
print(result.text) # Full Markdown textprint(result.metadata) # Pages, blocks, bounding boxes# Cloud mode — higher-accuracy PDF parsingparser=Parser(mode="cloud", api_key="your_key")
result=parser.parse("invoice.pdf")
print(result.text)
print(result.tables) # Structured table dataprint(result.blocks[0].bbox) # Bounding-box traceability

CLI

# Parse a PDF to Markdown
docslight parse document.pdf --mode cloud -o document.md
# Parse to JSON or standard JSON
docslight parse scan.png --mode cloud --format json -o scan.json
docslight parse scan.png --mode cloud --format standard-json -o standard.json
# Parse and write a ZIP archive
docslight parse invoice.pdf --mode local --format zip -o invoice.zip
# Field extraction (cloud mode)
docslight extract invoice.pdf --mode cloud --fields invoice_no,date,total
docslight extract invoice.pdf --schema schema.json
docslight extract invoice.pdf --document-types document-types.json
# Local LLM extraction
docslight extract invoice.pdf --mode local --fields invoice_no,total --local-llm-provider ollama --local-llm-model llama3.1
# Convert local parse JSON to standard parse JSON
docslight convert-parse-json parse.json -o standard.json
# Start the local API server
docslight web --host 127.0.0.1 --port 8000 --debug

CLI commands

docslight parse INPUT [OPTIONS]
docslight extract INPUT [OPTIONS]
docslight convert-parse-json INPUT [OPTIONS]

Common parse/extract options

OptionValues / defaultDescription
INPUTFile pathDocument path to process.
--modecloud, local; default from config/env or cloudSelect ComPDF Cloud or local offline processing.
--api-keyStringCloud API key. Overrides COMPDF_API_KEY.
--base-urlURL; default https://api-server.compdf.comCloud API base URL. Overrides DOCSLIGHT_BASE_URL.
--local-parserStringLocal parser selector. Currently reserved for local parser configuration.
--local-llm-providerollama, openai, openai-compatible; default ollama when any local LLM option is usedLocal extraction LLM provider.
--local-llm-modelStringLocal extraction LLM model. Required for local LLM extraction.
--local-llm-base-urlURLLocal LLM endpoint. Ollama defaults to http://localhost:11434; OpenAI-compatible providers require this value.
--local-llm-api-keyStringLocal LLM API key. Ollama defaults to ollama.

parse options

OptionValues / defaultDescription
--output, -oFile pathWrite output to a file instead of stdout.
--formatmarkdown, json, standard-json, zip; default markdownOutput format. If omitted and --output ends with .zip, DocSlight infers zip.

markdown writes parsed Markdown. json writes the SDK parse result. standard-json writes the standard parse JSON schema. zip writes the raw parse archive and should normally be used with --output.

extract options

OptionValues / defaultDescription
--output, -oFile pathWrite extracted JSON to a file instead of stdout.
--fieldsComma-separated names, for example invoice_no,totalFields to extract.
--schemaJSON file pathExtraction schema JSON file. The CLI reads this file and passes the JSON object to extract; a common schema is {"fields": ["invoice_no", "date", "total"]}. JSON Schema-style objects with properties are also accepted.
--document-typesJSON file pathDocument type routing file. The JSON root must be a list, for example ["invoice", "receipt"].

Example schema.json:

{
"fields": ["invoice_no", "date", "total"]
}

convert-parse-json options

OptionValues / defaultDescription
INPUTJSON file pathLocal parse JSON payload to convert. The JSON root must be an object.
--output, -oFile pathWrite converted standard parse JSON to a file instead of stdout.

Environment variables and config file

VariableDescription
COMPDF_API_KEYAPI key for cloud mode.
DOCSLIGHT_MODEProcessing mode: cloud or local; default cloud.
DOCSLIGHT_BASE_URLCloud API base URL; default https://api-server.compdf.com.
DOCSLIGHT_TIMEOUTCloud request timeout in seconds; default 30.
DOCSLIGHT_LOCAL_PARSERLocal parser selector.

DocSlight also reads ~/.docslight/config.toml. Values are applied in this order: built-in defaults, config file, environment variables, then explicit SDK or CLI arguments.

mode = "cloud"api_key = "your-api-key"base_url = "https://api-server.compdf.com"timeout = 30local_parser = "paddleocr"# reserved for local parser configuration
[local_llm]
provider = "ollama"model = "llama3.1"base_url = "http://localhost:11434"api_key = "ollama"timeout = 120

The CLI exposes the main local LLM settings as flags. Advanced local LLM provider settings such as extra_body are available through the SDK or ~/.docslight/config.toml.

Docker

git clone https://github.com/ComPDF/docslight.git
cd docslight
docker compose -f docker/docker-compose.yml up
# Open http://127.0.0.1:3022

Comparison

CapabilityDocSlightMinerUPDF-Extract-KitExtractThinker
PDF Parsing⚠️
OCR Support⚠️
Data Extraction
Web UI
CLI
Python SDK⚠️
Cloud API
Enterprise Deployment
Markdown Output⚠️
JSON Output
Multi-language OCR⚠️⚠️
Commercial Support

Architecture

┌─────────────────────────────────────────────────────────────────────────────────┐
│ DocSlight Open-Source Document Parser & Extractor │
│ (LGPL License | Local + Cloud Dual Mode) │
└─────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Access Layer(Entry Points) │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────┐ ┌────────────────────────┐ ┌───────────────────┐ │
│ │ Docker Web UI(Primary) │ │ CLI │ │ Python SDK │ │
│ │ One-click container │ │ Command Line │ │ Native Code │ │
│ │ deployment, ready to │ │ Tool │ │ Integration │ │
│ │ use out of the box │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ docker compose -f │ │docslight parse <file> │ │ from docslight │ │
│ │ docker/compose.yml up │ │ │ │ import Parser │ │
│ │ │ │docslight extract <file>│ │ parser.parse() │ │
│ │ Browser access: │ │ │ │ │ │
│ │ http://localhost:3022 │ │ docslight web │ │ │ │
│ └──────────────────────────┘ └────────────────────────┘ └───────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Core Processing Router │
│ Auto-switch between Local and Cloud Engine via --mode/config │
└─────────────────────────────────────────────────────────────────────────────────┘
│
┌─────────────────┴─────────────────┐
│ │
▼ ▼
┌───────────────────────────────────┐ ┌─────────────────────────────────────┐
│ 🖥️ Local Mode(Lite Local) │ │ ☁️ Cloud Mode(Lite Cloud) │
│ (Free, Offline, CPU Support) │ │ (High Accuracy, API Key, GPU) │
├───────────────────────────────────┤ ├─────────────────────────────────────┤
│ • Input Formats: │ │ • Input Formats: │
│ PDF / Images / New Office │ │ + Legacy Office (.doc/.xls etc.)│
│ (.docx/.pptx/.xlsx) │ │ │
│ • Base OCR: PaddleOCR │ │ • High-Accuracy VLM OCR Engine │
│ • Basic Layout Analysis │ │ • Complex Layout (Tables/Formulas/ │
│ • Field Extraction: requires │ │ Multi-column) │
│ local LLM (Ollama/OpenAI │ │ • Built-in AI Field Extraction │
│ compatible) │ │ • Bounding Box (BBox) Traceability│
│ • Output: Markdown / JSON / Text │ │ • Output: Markdown / JSON / Text │
└───────────────────────────────────┘ └─────────────────────────────────────┘
│ │
└─────────────────┬─────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ AI Capability Layer(Engine Modules) │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────────────────────┐ │
│ │ OCR Engine │ │ Structure │ │ Field Extraction Module │ │
│ │ • Local: │ │ Analyzer │ │ • Template Extraction │ │
│ │ PaddleOCR │ │ • Block │ │ • Custom Fields │ │
│ │ • Cloud: │ │ Classification│ │ • Rules + LLM Combo │ │
│ │ VLM Engine │ │ • Table │ │ • BBox Traceability │ │
│ │ │ │ Detection │ │ │ │
│ │ │ │ • Key-Value │ │ │ │
│ │ │ │ Mapping │ │ │ │
│ │ │ │ • Formula │ │ │ │
│ │ │ │ Recognition │ │ │ │
│ └──────────────────┘ └──────────────────┘ └─────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Output & Ecosystem Layer │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────────────────────┐ │
│ │ Standard │ │ AI Ecosystem │ │ Enterprise Extensions │ │
│ │ Output │ │ Integration │ │ (SaaS / Private Deployment) │ │
│ │ Formats │ │ │ │ │ │
│ │ • Markdown │ │ • LangChain │ │ • Workflow Orchestration │ │
│ │ • JSON │ │ • LlamaIndex │ │ • Knowledge Base / DMS │ │
│ │ • Text │ │ • CrewAI │ │ • RBAC / Audit Logs │ │
│ │ • with BBox │ │ • AutoGen │ │ • Smart Review / Custom Rules│ │
│ │ Coordinates│ │ • Haystack │ │ • Multi-tenancy / Private │ │
│ │ Tracing │ │ │ │ Deployment │ │
│ └───────────────┘ └───────────────┘ └───────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────────────────┐ │
│ │ Target Scenarios: RAG Pipelines / AI Agents / Enterprise Document │ │
│ │ Automation / Intelligent Document Processing (IDP) │ │
│ └──────────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────────┘

Built for AI Agents & RAG

DocSlight helps developers build modern AI document workflows with open-source PDF parsing and open-source document data extraction.

Common Applications

  • RAG systems
  • AI assistants
  • Enterprise knowledge bases
  • AI agent workflows
  • Document search engines
  • MCP applications
  • Intelligent document processing (IDP) for open-source workflows at any scale

Compatible Ecosystem

  • OpenAI
  • Claude
  • Ollama
  • LangChain
  • LlamaIndex
  • CrewAI
  • AutoGen
  • Haystack

Typical Workflow

PDF / Image / Office Document
↓
docslight
↓
Markdown / JSON Output
↓
Vector Database
↓
LLM / AI Agent
↓
Answers & Automation

Benchmark

Model TypeMethodsParametersOverall Score↑TextEdit↓FormulaCDM↑TableTEDS↑TableTEDS-S↑Read OrderEdit↓
DocSlight (Cloud)Specialized VLMs0.9B96.450.032197.7694.8097.020.131
MinerU2.5-ProSpecialized VLMs1.2B95.750.03697.4593.4295.920.120
GLM-OCRSpecialized VLMs0.9B95.220.04497.1892.8395.390.133
PaddleOCR-VL-1.5Specialized VLMs0.9B94.930.03896.8991.6794.370.130
Ovis2.6-30B-A3BSpecialized VLMs30B93.700.03595.1789.4492.400.135
Logics-Parsing-v2Specialized VLMs4B93.330.04195.6588.4291.980.137
HunyuanOCRSpecialized VLMs1B89.950.08887.6891.0193.230.171
Qwen3-VL-235BGeneral VLMs235B89.780.06392.5583.0786.750.166
Dolphin-v2Specialized VLMs3B89.500.06991.0184.4087.440.150
GPT-5.2General VLMs-86.590.11488.2182.9587.930.193
Mistral OCRSpecialized VLMs-85.660.09789.9176.7880.930.171
Nanonets-OCR-sSpecialized VLMs3B83.610.10881.4680.1884.510.213
MarkerPipeline Tools-78.440.15785.2465.7773.240.243

Methodology: Based on real human-annotated data and measured with character-level accuracy. The test set covers 500+ enterprise documents, including invoices, contracts, tables, and reports. The dataset is available at benchmarks/dataset.

Package Variants

PackageDescription
docslightCore CLI + Python SDK
pip install "docslight"

Support

Have suggestions? Start a discussion. If you find DocSlight useful, please consider giving us a ⭐ Star on GitHub. It helps us grow and improve.

License

DocSlight is released as open source under the LGPL.

Commercial / Enterprise licenses with support for GPU self-hosted deployment are available at compdf.com.

Built by the ComPDF team.
Website · Docs · Enterprise Inquiries