pdf-parse

Pure TypeScript PDF parser for extracting text, images, tables, and metadata in Node.js and browsers.

Library
npm
v2.4.5
218stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
41/100Fair
Development Activity12
Maintenance44
Community32
Maturity36
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture82
Code Quality85
Innovation78
Learning Curve100

pdf-parse is a pure TypeScript library built on Mozilla’s pdfjs-dist for extracting text, images, tables, and document metadata from PDF files. It runs identically in Node.js, browsers, and web workers, exposing a single PDFParse class with dedicated methods for header validation, metadata extraction, plain text and paragraph reconstruction, page-rendering to PNG, embedded image extraction, and table detection.

The library ships as CJS and ESM builds with full TypeScript typings, a Node-only submodule for lightweight header checks via range requests, and an optional canvas-based renderer for image and screenshot output. A companion command-line interface wraps the same functionality for scripted batch processing without writing any code, and the project publishes typed exceptions (PasswordException, InvalidPDFException, and others) so callers can handle protected or malformed PDFs explicitly.

What You Get

  • A single PDFParse class covering header checks, metadata, text, paragraphs, screenshots, images, and tables
  • CJS, ESM, and browser builds published from one codebase with matching TypeScript declarations
  • A global CLI (pdf-parse) for extracting text, images, or tables from the terminal without writing code
  • Typed exception classes (PasswordException, InvalidPDFException, FormatError, and more) for precise error handling
  • A Node-only getHeader() helper that validates PDF magic bytes and reads file size via a lightweight HTTP range request before downloading the full file

Common Use Cases

  • Extracting searchable text from uploaded PDFs in a Next.js or Node.js API route
  • Generating page thumbnails or full-page PNG screenshots for a PDF viewer UI
  • Pulling structured tables out of invoices or reports for downstream data processing
  • Validating a remote PDF URL’s size and signature before committing to a full download

Under The Hood

Architecture The core class PDFParse (src/pdf-parse/PDFParse.ts) wraps pdfjs-dist’s PDFDocumentProxy, exposing typed methods (getHeader, getInfo, getText, getScreenshot, getImage, getTable) that each operate on a lazily-loaded document and return typed Result classes (TextResult, ImageResult, ScreenshotResult, HeaderResult, InfoResult) defined as separate files under src/pdf-parse/. The package is split into independent build targets — src/pdf-parse (shared core), src/node (Node-only helpers like the range-request logic behind getHeader), src/worker (web worker glue with canvas support), and a pro entry point referenced in the exports map — each compiled by its own Vite/Rolldown/tsconfig pipeline and published as parallel CJS/ESM/browser bundles under one exports map. This is a modular, single-responsibility-per-file layered design: PDFParse is the single façade, Result classes hold data plus convenience accessors such as getPageText, and Exception.ts centralizes typed error translation from pdfjs-dist’s internal errors.

Tech Stack pdfjs-dist is the core PDF rendering engine, consumed via pdfjs-dist/legacy/build/pdf.mjs; @napi-rs/canvas is an optional native dependency for server-side canvas rendering of screenshots and images, explicitly disabled in browser builds via the package’s browser field. Build tooling combines Vite and Rolldown (a Rust-based bundler) for the browser/worker/pro targets, plus esbuild directly for the Node CJS/ESM outputs, orchestrated through a postbuild script. TypeScript runs in strict mode targeting ES2022 with NodeNext module resolution. Testing runs on Vitest with a dedicated coverage config, and Biome handles both linting and formatting in a single tool. CI is GitHub Actions with dedicated workflows for unit tests, cross-runtime integration tests, unsupported-environment tests, npm publishing, and a GitHub Pages deployment for a live demo and generated API docs.

Code Quality Tests are organized under numbered unit suites (one per public method, plus edge cases for passwords, geometry, malformed PDFs, and multi-file handling) and a separate integration suite that verifies the package under real ESM, CJS, Jest, and AVA consumption scenarios plus a TypeScript compilation check — a more thorough approach than typical unit-only coverage. Vitest with v8 coverage plus Codecov tracks coverage over time. Every public class and method carries structured documentation comments that also feed a published API reference site. Error handling is explicit and typed: pdfjs-dist’s internal exceptions are translated into typed classes callers can instanceof-check, rather than surfacing raw library errors.

API Design The public surface is a single class instantiated once per document, with one method per extraction concern, each accepting a shared parameters shape for page selection so the calling convention stays consistent across methods, and each returning a typed result object with both raw data and convenience accessors. Getting started requires one import and a destroy() call to free memory. Migration friction from the older major version is addressed directly with a side-by-side code comparison and a backward-compatible method. Documentation is unusually extensive for an open-source package: multiple dedicated reference docs covering options, the CLI, worker usage, and troubleshooting, plus a wide set of runnable examples spanning CJS, ESM, HTML/CDN, worker, and large-file scenarios.

Used by 23 apps in this directory

JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

65,696

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
90
Repo Health
78
Technical
64
Dependency
Built with
JavaScript95%
Updated 3 days ago
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

10,992

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
80
Repo Health
69
Technical
63
Dependency
Built with
TypeScript92%
Updated 1 weeks ago
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,260

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated 2 days ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

51,521

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
TypeScript
98%
Apache 2.0

Cline

AI Code Assistants

67,585

An open-source AI coding agent that lives in your editor and terminal — reads and edits your codebase, runs commands, browses the web, and requires human approval for every action by default.

View details
89
Repo Health
74
Technical
65
Dependency
Built with
TypeScript98%
Updated 2 days ago
Python
50%
MIT

Docs

File Storage · CMS

16,788

Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.

View details
88
Repo Health
81
Technical
71
Dependency
Built with
Python50%
TypeScript42%
Updated yesterday
TypeScript
72%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

177,290

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
65
Dependency
Built with
TypeScript72%
Python14%
Updated yesterday
TypeScript
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,427

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
86
Repo Health
77
Technical
63
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 3 weeks ago
TypeScript
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,643

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript49%
Go45%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search