How to compress a PDF
- Drop your PDF into the zone above, or click to browse and select it.
- Choose an image compression level. Recommended (the default) re-encodes embedded photos and scans as JPEG at a lower quality and resolution — this is usually where most of the size reduction comes from. Basic is a lighter touch, Strong prioritises the smallest file, and Off leaves every image pixel-for-pixel unchanged.
- Choose your other options. Remove metadata strips the document title, author, creation date, and other invisible properties. Remove annotations removes comments and markup added to the document.
- Click Compress & download. The tool shows the before and after file sizes, how many images were recompressed, and the optimised PDF downloads to your device.
Everything runs in your browser using pdf-lib and the browser's own Canvas API for image re-encoding.
No file is sent to a server — open DevTools (F12) → Network while processing to verify zero upload requests.
What makes a PDF large
Most people assume compression is a single operation with a predictable outcome. In practice, the amount of size reduction you can achieve depends entirely on what is making the file large. There are four main sources of PDF file size, each requiring a different approach.
- Embedded images: By far the most common cause of large PDFs. A document with scanned pages, product photography, or design graphics embeds each image at its original resolution. A single full-page photograph at 300 DPI can be 3–5 MB. A 30-page scanned document at 200 DPI can easily reach 50 MB. This is what the image compression option above addresses: it re-encodes the common cases — plain JPEG photos, and uncompressed or PNG-style RGB/grayscale images — at a lower quality and resolution, right in your browser.
- Embedded fonts: PDF can embed complete font files for every typeface used in the document. A single professional OpenType font can be 500 KB–2 MB. A PDF using three or four custom fonts carries several megabytes of font data that contributes nothing to the visual output for readers who never need to edit the document. Subsetting (embedding only the characters actually used) reduces this significantly, but few export tools do it aggressively. This tool does not touch fonts.
- Metadata and document overhead: Author, title, keywords, revision history, comments, annotations, and internal cross-reference tables add overhead that has nothing to do with what readers see. For PDFs exported from design tools like Adobe Illustrator or InDesign, this overhead can be substantial — sometimes 30–40% of the total file size. The metadata and annotation options above remove this.
- Unused and duplicate objects: PDF is an append-only format. When you edit a PDF in most tools, the old version of each modified object stays in the file as a dead object — the file grows but nothing visible changes. Re-saving with object compression removes these dead objects, which this tool always does.
This tool addresses the first, third, and fourth categories. It does not subset or remove embedded fonts, and it deliberately skips some image types for safety — see the limits below.
When to compress a PDF
- Email attachments — many email providers cap attachments at 10–25 MB. Recompressing embedded photos and scans, plus stripping metadata and unused resources, can bring a bloated PDF well under the limit.
- Document portals and upload limits — government portals, insurance sites, and HR systems often impose strict file size limits on uploads, and scanned documents are usually what pushes a PDF over them.
- Removing author metadata before sharing — a report created in Word carries author name, company, and revision history in the PDF metadata by default. Stripping it before sending removes that information.
- Cleaning up PDFs exported from design tools — Illustrator and InDesign exports often include significant metadata overhead that contributes nothing to the document content.
- Archiving — removing unused objects and annotations produces a cleaner, more compact file for long-term storage.
How it works under the hood
pdf-lib parses the PDF and walks every embedded image object directly. For a plain JPEG image (the most
common case — most photos and scans embedded in PDFs are already JPEG), the raw image bytes are decoded
with createImageBitmap, drawn to an off-screen canvas at the target resolution, and
re-encoded as a new, smaller JPEG with canvas.toBlob. For an uncompressed or PNG-style
RGB/grayscale image, the raw pixel samples are decoded, assembled into image data, and re-encoded the
same way. The new image replaces the old one at the same internal reference, so every page that used
it — including a logo or photo repeated across many pages — automatically picks up the smaller version.
Downsampling an image's pixel dimensions never changes how large it appears on the page: a PDF places every image onto a fixed rectangle via a transform in the page's content stream, so a lower-resolution image simply fills the same box at a lower effective DPI. Images with transparency, CMYK or indexed colour, or unusual bit depths are left untouched rather than risk a wrong colour conversion or a broken soft mask. After recompressing, the tool re-parses the entire result with pdf-lib as a safety check; if anything about the rewritten file looks wrong, it silently falls back to the metadata-only result instead of handing back something broken.
Stripping metadata removes the document information dictionary, which stores title, author, subject,
keywords, creator, and producer fields. These are invisible to readers but add bytes to every copy of
the file. Removing annotations deletes the annotation arrays attached to each page — comments, highlights,
and markup left by reviewers. Saving with useObjectStreams: true also compresses the
document's internal cross-reference table.
Limits and what to expect
- Skipped image types: images with transparency, CMYK or indexed colour, or unusual bit depths are left unchanged rather than risk corrupting them. The result screen reports how many images were recompressed versus skipped so you can see which case you hit.
- Inline images: a small number of PDFs embed images directly inside the page content stream instead of as a separate object. Those are not recompressed.
- Already-optimised PDFs: PDFs exported from modern tools with compression already applied may see little or no size reduction — the tool only keeps a re-encoded image if it is actually smaller.
- Very large or many images: recompression happens one image at a time in your browser tab, so a PDF with dozens of large photos will take noticeably longer than a text-only document.
- Password-protected PDFs: must be unlocked before use.
- Annotation removal scope: removes standard annotations (comments, highlights, sticky notes). Interactive form fields are not removed by the annotations option.
- Browser support: Chrome 90+, Firefox 90+, Safari 15+, Edge 90+.
File size targets for common use cases
Different destinations have different limits, and knowing the target helps you decide how much compression you actually need:
- Email attachments: Gmail caps at 25 MB, Outlook at 20 MB, many corporate mail servers at 10 MB or 5 MB. If your PDF is over 20 MB from embedded photos or scans, try the Strong image compression level first — it's the setting most likely to bring a large PDF under an email limit.
- Web upload portals: Government forms, insurance portals, HR systems, and legal submission systems typically impose 5–10 MB limits. Some are stricter — 2 MB is common for passport and document scans. Strong downsamples images to 1400px on the longest side, which is enough resolution for on-screen review but well below print quality.
- Cloud storage sharing: No size limits in practice, but very large PDFs take time to open in browser-based viewers. Under 5 MB is comfortable for most viewers.
- Print-ready PDFs: Print files should not be compressed aggressively — images need to stay at 300 DPI minimum, which is usually well above the pixel dimensions this tool's presets target. For print submissions, use Off for image compression and only strip metadata.
When this is not enough
This tool's image compression handles the common case well: plain JPEG photos and simple RGB or grayscale scans. A few things it deliberately does not attempt, where a dedicated desktop tool remains the better choice:
- CMYK images, from print-workflow PDFs: skipped here to avoid a wrong colour conversion. Adobe Acrobat Pro's PDF Optimizer or Ghostscript (
-dPDFSETTINGS=/ebook) handle CMYK correctly. - Transparent images and soft masks: skipped here for the same reason. A desktop tool with full image-compositing support will handle these correctly.
- Font subsetting: if a PDF is large mainly because of embedded font files rather than images, this tool won't help — that requires rewriting the font program itself, which Ghostscript and Adobe Acrobat Pro can do.
- Maximum possible compression regardless of quality loss: Ghostscript's
/screensetting or repeated passes in Acrobat Pro can go further than this tool's Strong preset, at a visibly lower quality.
For everything else — metadata-heavy exports from office or design tools, and PDFs whose size mostly comes from ordinary embedded photos or scans — the browser-based approach here is genuinely a real fix, not just a stopgap, and nothing ever leaves your device.
Privacy compared to other PDF compressors
Online PDF compressors upload your file to a server, compress it there, and serve it back. The irony is that compressing a sensitive document — a contract, financial report, or patient record — on a third-party server exposes it to the same risks as any other upload. You are trusting a company you have never audited with your most private documents.
keptlocal compresses entirely in your browser. The PDF bytes move from your disk to your browser's memory, get optimised, and download back to your disk. No server is involved. Verify it in the Network tab — zero outbound file transfers.