FileSlim logo - compress images and PDFs online free
FileSlim
Last Updated:

PDF Compression API for Developers

Add PDF compression to your app without paying per-call REST fees. @fileslim/compress is an MIT-licensed JavaScript SDK that runs entirely in the user's browser.

Quick start (3 steps):

  1. Install: npm install @fileslim/compress
  2. Import compressPdf and pass a File or Blob.
  3. Get back a CompressedFile with the new Blob and stats.

No backend. No API keys. No per-call fees. Runs on the user's CPU.

Juraj Cukan

Founder, CEO & Lead Developer

Student, Comenius University - Faculty of Mathematics, Physics and Computer Science
Full-Stack Developer
Compression Algorithm Specialist
50M+ Files Processed

Juraj is a Computer Science student at Comenius University in Bratislava, Slovakia, and the sole creator of FileSlim. Frustrated with inefficient and expensive compression tools, he built FileSlim from the ground up as a free, privacy-first alternative. Working entirely alone, Juraj developed every aspect of the platform—from the compression algorithms to the user interface—ensuring complete browser-based processing that never uploads files to servers. His work has helped users worldwide compress over 50 million files while maintaining complete privacy and achieving 60-90% file size reductions.

PDF Compression in 6 Lines

import { compressPdf } from '@fileslim/compress';
import { AD_SLOTS } from '@/config/adsense';

const file = inputEl.files[0];          // user-selected PDF
const result = await compressPdf(file, { preset: 'balanced' });

console.log(result.originalSize, '→', result.compressedSize);
downloadLink.href = URL.createObjectURL(result.blob);

Want a specific target? Pass { targetBytes: 1_000_000 } and the SDK iteratively downsamples embedded images until the output fits.

Pricing vs Hosted PDF APIs

Costs below come from each vendor's public pricing page (May 2026). Hosted APIs charge per request; the FileSlim SDK runs on the user's device.

ProviderModelTypical CostPrivacy
@fileslim/compressClient-side SDK$0 — no per-call feeFiles never leave the browser
Adobe PDF Services APIREST~$0.05 / compression callFiles uploaded to Adobe
ILovePDF APIREST + credit packsFrom $9 / mo (Lite plan)Files uploaded to ILovePDF
PDF.co APIREST, pay-as-you-go~$0.005 / call (volume-tiered)Files uploaded to PDF.co
PSPDFKit / NutrientSDK (commercial license)Enterprise quoteSelf-hosted option available

Why Client-Side Beats a Hosted REST API

Privacy by default

PDFs never leave the user's browser. No upload, no logs, no compliance review for handling third-party documents. Useful for legal, healthcare and fintech apps.

Zero per-call cost

Hosted APIs bill per request. A consumer app with 100k monthly compressions hits ~$5,000/mo on Adobe. The SDK is free regardless of volume — cost is constant.

Lower latency

No upload round-trip. Compression starts the moment the user drops a file. Typical 10 MB PDF compresses in 3–8 s on a modern laptop — usually faster than upload + queue + download.

Zero ops

No servers to scale, no rate limits to monitor, no API key rotation. The SDK ships as a static asset alongside the rest of your bundle.

When a Hosted API Still Makes Sense

Client-side compression isn't always the right answer. Pick a hosted PDF API instead when:

  • You need server-to-server batch processing (no human in the loop).
  • Inputs come from systems that can't run JavaScript (a Postgres trigger, an SFTP drop).
  • You need OCR, form-field manipulation or signing — the SDK is compression-only.
  • You're processing PDFs your end-users can't open in a browser (multi-GB files).

Frequently Asked Questions

Does FileSlim provide a hosted PDF compression REST API?

No. FileSlim ships @fileslim/compress, a client-side JavaScript SDK that runs in the user's browser using WebAssembly. There is no REST endpoint to call and no per-request fee — you bundle the SDK into your app and compression happens on the user's device.

Why use a client-side SDK instead of a REST API?

Three reasons: (1) Privacy — PDFs never leave the user's device, which matters for legal, medical and financial documents. (2) Cost — there are no per-call fees, no bandwidth costs and no rate limits. (3) Latency — no round-trip to a server, so compression starts immediately.

How do I install the SDK?

Run `npm install @fileslim/compress` (or the yarn/pnpm/bun equivalent). The package is MIT-licensed and works in any modern browser-based JavaScript runtime — React, Vue, Svelte, vanilla JS or Electron.

What PDF compression options does the SDK expose?

Built-in presets: 'quick-share' (aggressive), 'balanced' (recommended), 'high-quality' (print-friendly). You can also pass a target size in bytes and the SDK iteratively downsamples embedded images to hit it.

Can I integrate the SDK into a Node.js backend?

The SDK is browser-first because it relies on WebAssembly compiled for browser runtimes and Web Workers. For Node servers, run the SDK inside a headless Chrome instance (Puppeteer/Playwright) or use a serverless function with a Wasm-compatible runtime — but the canonical use case is in-browser compression.

How does the SDK compare to Adobe PDF Services API on pricing?

Adobe PDF Services charges per transaction (around $0.05 per compression call at standard rates). FileSlim's SDK is free and runs on the client, so cost scales with zero — useful for high-volume consumer products where API fees would be prohibitive.

What's the bundle size of @fileslim/compress?

Around 350 KB gzipped for the core PDF compression path. WebAssembly modules are lazy-loaded on first use, so the initial JS payload is smaller. We recommend dynamic import() to defer the SDK until the user actually compresses something.

Does the SDK support batch compression?

Yes. The SDK exposes a batch() helper that uses a Web Worker pool sized to hardwareConcurrency - 1, so multiple PDFs compress in parallel without blocking the UI.

What formats does the SDK support besides PDF?

JPEG, PNG, WebP, AVIF for images and PDF for documents. Office formats (DOCX, PPTX, XLSX) are supported in FileSlim's web app but not currently in the SDK — the SDK roadmap includes DOCX support.

Is the SDK production-ready?

Yes. It powers fileslim.com, which processes user files daily without server-side infrastructure. The library is MIT-licensed and published as @fileslim/compress on npm. Source on GitHub.

Ship PDF compression today

Install @fileslim/compress and add PDF compression to your app — MIT-licensed, no API key, no server.

Get more FileSlim in Google

Tell Google you want to see FileSlim guides and tools more often. Takes one click and you stay on this page.

Make us a preferred source