The examples/ directory contains runnable scripts demonstrating SDK features.
Set the DOCLING_URL environment variable to point to your Docling Serve instance:
export DOCLING_URL=http://localhost:5001Run any example with tsx:
npx tsx examples/01-basic-api.tsOr use the predefined npm scripts:
npm run examples:basic-api
npm run examples:streaming
npm run examples:async
npm run examples:cli
npm run examples:s3
npm run examples:typescriptKey concepts: health check, synchronous conversion, async conversion with ZIP output, convertToFile
Demonstrates the fundamental API client workflow: check server health, convert a PDF to markdown (sync inbody response), submit an async conversion and download the ZIP result, and use convertToFile for file-based output.
npx tsx examples/01-basic-api.tsKey concepts: convertToStream, convertStreamToFile, content streaming, ZIP streaming
Shows memory-efficient processing by streaming converted content directly to disk and streaming ZIP results from async submissions.
npx tsx examples/02-streaming.tsKey concepts: convertFileAsync, task.poll(), task.getResult(), manual polling
Demonstrates programmatic control over async tasks: submit a conversion, manually poll for status updates, and retrieve results when complete.
npx tsx examples/03-async-processing.tsKey concepts: chunkHybridSync, chunkHierarchicalSync, chunkHybridFileAsync, chunk options
Shows both chunker types (HybridChunker and HierarchicalChunker) with sync and async modes, including source-based chunking from URLs.
npx tsx examples/04-chunking.tsKey concepts: DoclingCLIClient, convert, batch, processDirectory, progress events
Demonstrates CLI client features: single file conversion, batch processing, directory processing, and progress tracking through the event emitter.
npx tsx examples/04-cli-client.tsKey concepts: quick-start chunking workflow, basic options
A minimal chunking example showing the fastest path from document to chunks.
npx tsx examples/05-chunking-quickstart.tsKey concepts: convertFromS3, convertWithTarget, S3Config, S3 target
Demonstrates reading documents from S3 and uploading conversion results to S3.
npx tsx examples/05-s3-integration.tsKey concepts: type guards, Result pattern, safeConvert, OpenAPI types, Zod validation
A comprehensive TypeScript usage example showing type-safe patterns, discriminated unions, Result types, and validation.
npx tsx examples/06-typescript-types.tsnpx tsx examples/runtimes/node.ts
# or: npm run examples:nodeDemonstrates Node.js-specific features: file system access, stream.pipe(), connection pooling.
bun run examples/runtimes/bun.ts
# or: npm run examples:bunDemonstrates Bun.file() for input and Bun.write() for output.
deno run --allow-net --allow-env --allow-read examples/runtimes/deno.ts
# or: npm run examples:denoDemonstrates npm: imports, Deno.readFile(), and Deno.writeFile().
vite examples/runtimes/browser
# or: npm run examples:browserDemonstrates browser-based API client usage with file input and the docling-sdk/browser entry point.
cd examples/runtimes/cloudflare-worker && wrangler dev
# or: npm run examples:workerDemonstrates a Cloudflare Worker that accepts file uploads and returns converted markdown.
npm run examples:web-ocrOpens a full demo application at http://localhost:5173 with:
- Drag-and-drop file input
- WebGPU/WASM backend selection
- Real-time streaming output
- Model loading progress
- Multiple output formats (Markdown, HTML, JSON, tables, overlays)
The demo source is in examples/web-ocr/.
- Getting Started -- first conversion
- API Client -- API client guide
- CLI Client -- CLI client guide
- Web Client -- Web OCR guide