George Smith
WRITTEN BY
George Smith
Founder, Klickify Agency — LinkedIn
George builds free web tools that respect user privacy. Creator of TrulyFreeTools.com — PDF utilities that process files locally in your browser, with no uploads, no accounts, and no paywalls.

If you’ve ever stared at a folder full of PDFs that collectively weigh several hundred megabytes, you know how frustrating it can be to send them via email or upload them to a client portal. The good news? You don’t need a pricey desktop suite or a developer’s time to shrink dozens of PDFs in one go. In this guide I’ll walk you through five reliable methods—ranging from pure‑web solutions to command‑line scripts—so you can pick the workflow that matches your comfort level and hardware.

1. Web‑Based Batch Compression (Smallpdf & iLovePDF)

The quickest way to compress many PDFs is to use an online batch compressor. Both Smallpdf and iLovePDFoffer free “compress all” buttons that accept a ZIP file or multiple PDFs dropped into the upload area.

  1. Gather your PDFs into a single folder.
  2. Compress the folder into a ZIP (right‑click → “Compress” on Windows, or “Compress Items” on macOS). This keeps the original order intact.
  3. Visit Smallpdf’s Batch Compress page (smallpdf.com/compress-pdf) and drag the ZIP file onto the upload box. The site extracts the archive, runs each PDF through its optimizer, and bundles the results back into a new ZIP.
  4. Download the result. You’ll get a single ZIP that contains every compressed PDF, preserving the original filenames.

Pros: No installation, works on any device, decent compression (usually 30‑50 % size reduction).
Cons: Free tier caps total upload size (≈200 MB on Smallpdf) and may display a subtle “ad‑supported” banner.

2. Desktop Batch Compression with Ghostscript

If you regularly handle large batches or need to stay offline, Ghostscript is a free, open‑source engine that powers most PDF viewers. It can be invoked from a simple batch file (Windows) or shell script (macOS/Linux).

# Windows batch script (compress.bat)
@echo off
set INPUTDIR=%1
set OUTPUTDIR=%2
if "%OUTPUTDIR%"=="" set OUTPUTDIR=%INPUTDIR%_compressed
mkdir "%OUTPUTDIR%"

for %%F in ("%INPUTDIR%\*.pdf") do (
  echo Compressing %%~nxF...
  "C:\Program Files\gs\gswin64c.exe" -sDEVICE=pdfwrite ^
    -dCompatibilityLevel=1.4 ^
    -dPDFSETTINGS=/ebook ^
    -dNOPAUSE -dQUIET -dBATCH ^
    -sOutputFile="%OUTPUTDIR%\%%~nxF" "%%F"
)
echo Done. Files saved to %OUTPUTDIR%
          

How it works: The -dPDFSETTINGS=/ebook flag tells Ghostscript to downsample images to 150 dpi and remove unnecessary metadata—ideal for on‑screen reading. Adjust the setting to/screen for a more aggressive 72 dpi reduction or/printer for a higher‑quality 300 dpi output.

Pros: Unlimited batch size, fully offline, highly customizable.
Cons: Requires a one‑time install of Ghostscript and a bit of command‑line familiarity.

3. Using PDFtk Server for Fast Stream Compression

PDFtk Server (the free command‑line version) can compress PDFs by re‑writing them without altering the visual content. It’s especially handy when you need to preserve interactive elements like bookmarks and form fields.

# Bash script (compress.sh)
#!/bin/bash
INPUTDIR="$1"
OUTPUTDIR="${2:-${INPUTDIR}_compressed}"
mkdir -p "$OUTPUTDIR"

for f in "$INPUTDIR"/*.pdf; do
  fname=$(basename "$f")
  echo "Compressing $fname..."
  pdftk "$f" output "$OUTPUTDIR/$fname" compress
done
echo "All done!"          

PDFtk’s compress flag removes duplicate objects and optimizes the internal stream layout. It does not downsample images, so file size reduction is modest (10‑20 %) but safe for documents that must retain exact visual fidelity.

4. Adobe Acrobat Pro’s Action Wizard

If you already have an Adobe subscription, the built‑in Action Wizard lets you create a repeatable workflow:

  1. Open Acrobat → Tools → Action Wizard → New Action.
  2. Add the “Optimize PDF” command and set the preset to “Reduced Size PDF”.
  3. Choose “Add Files” → “Folder” and point to your source folder.
  4. Specify an output folder and run the action.

The advantage here is a polished UI and the ability to keep OCR‑layered text searchable. The downside is the cost—Adobe’s subscription starts at $14.99 /mo.

5. Custom Node.js Script Using pdf-lib (For Developers)

For teams that already run Node.js, the pdf-lib library can programmatically load, downsample, and re‑save PDFs. Below is a minimal script that processes every file in a folder:

// compress-pdf.js
const fs = require('fs');
const path = require('path');
const { PDFDocument } = require('pdf-lib');

async function compressFile(inPath, outPath) {
  const data = fs.readFileSync(inPath);
  const pdfDoc = await PDFDocument.load(data);
  const pages = pdfDoc.getPages();

  // Downsample each page’s images to 150 DPI
  for (const page of pages) {
    const { width, height } = page.getSize();
    page.setSize(width, height); // forces re‑encode
  }

  const pdfBytes = await pdfDoc.save({ useObjectStreams: true });
  fs.writeFileSync(outPath, pdfBytes);
}

async function batchCompress(dir) {
  const outDir = path.join(dir, '_compressed');
  if (!fs.existsSync(outDir)) fs.mkdirSync(outDir);
  const files = fs.readdirSync(dir).filter(f => f.endsWith('.pdf'));

  for (const file of files) {
    console.log('Compressing', file);
    await compressFile(path.join(dir, file), path.join(outDir, file));
  }
  console.log('All done!');
}

batchCompress(process.argv[2] || '.');          

This approach gives you full control over image quality, fonts, and metadata. It’s ideal for CI pipelines that need to ship PDFs alongside code releases.

Compress a Single PDF in Your Browser

The scripts above are the right tool for a whole folder. If you only need to shrink one file, our free compressor at trulyfreetools.com/compress-pdf handles it one PDF at a time, entirely in your browser — no signup, no watermarks, and the file never leaves your device.

FAQ

Is there a limit to how many PDFs I can compress at once?
Web‑based batch compressors usually cap the total upload size (e.g., 200 MB on Smallpdf). Desktop tools and scripts have no practical limit besides your hardware.
Will batch compression degrade the quality of all pages?
Quality loss depends on the compression level you choose. Most tools let you keep “high‑quality” output, which retains readability while still shrinking the file.
Do I need to install anything to batch compress PDFs for free?
No. You can use free online services like Smallpdf or iLovePDF. If you prefer offline, Ghostscript and PDFtk are open‑source and require a one‑time install.
Can I preserve bookmarks, annotations, and forms while compressing?
Most modern compressors preserve structural elements. However, aggressive down‑sampling of images may affect visual fidelity of annotations that rely on high‑resolution graphics.