PDF Compressor

Published Updated

Repack a PDF's internal structure without touching its images or text, and get your original back if that does not make it smaller.

Lossless, and usually a small saving

This compressor does one thing: it opens the PDF with pdf-lib and saves it again using object streams, a PDF 1.5 feature that stores many small objects in one compressed block with a compact cross-reference stream. No image is recompressed and no page is redrawn, so the result looks and works exactly like the original.

The price of being is a modest saving. When the repacked file is not smaller, you get the original back rather than a bigger download.

Measured on five test files

Each file below was run through the site's own PDF Compressor component in Google Chrome 156, Chromium 153 (Playwright build, not Google Chrome), Firefox 155 and Playwright's WebKit build (not the Safari app). Sizes are the Chrome 156 results; the other three engines were within 2 bytes.

Test PDFBeforeAfterSaving
2-page report made with ReportLab2,853 bytes2,201 bytes22.9%
1 page printed to PDF from Chrome19,502 bytes16,940 bytes13.1%
1 page from the macOS print system12,908 bytes12,332 bytes4.5%
5 pages of uncompressed text30,577 bytes29,359 bytes4.0%
3 pages, one photo each360,494 bytes359,581 bytes0.3%

The uncompressed-text file shows a limit worth knowing: pdf-lib does not compress page content that was stored raw, so even plain text barely shrinks.

When you need a smaller file than this

Where the saving comes from: generated test files

To see which kinds of file shrink, we generated PDFs with pikepdf 9.11.0, Pillow and pdf-lib 1.17.1 and ran each through the same component in Chrome 156, Chromium 153, Firefox 155 and the WebKit build. Chrome 156 figures; the result message is the heading the tool showed.

Test PDFBeforeAfterSavingMessage
12 text pages, classic cross-reference table, compressed page streams8,974 bytes5,859 bytes34.7%Saved 35% of file size!
The same 12 pages with page streams stored uncompressed46,721 bytes43,620 bytes6.6%Saved 7% of file size!
The same 12 pages already packed in object streams5,653 bytes5,653 bytes (original returned)0%Your PDF was already well-optimized!
The same 12 pages saved linearized (fast web view)9,551 bytes6,062 bytes36.5%Saved 37% of file size!
200 text pages142,353 bytes86,751 bytes39.1%Saved 39% of file size!
12 pages saved again five times, each time with a new 60,000-byte version of page 1 appended309,805 bytes65,535 bytes78.9%Saved 79% of file size!
12 pages plus a 300,000-byte object that nothing in the file refers to309,140 bytes305,926 bytes1.0%Saved 1% of file size!
The same 585,945-byte JPEG stored twice, once per page1,173,175 bytes1,173,175 bytes (original returned)0%Your PDF was already well-optimized!
2,000 text pages written by pdf-lib2,136,611 bytes2,136,611 bytes (original returned)0%Your PDF was already well-optimized!
40 scan-like JPEG pages (Pillow)56,183,134 bytes56,175,163 bytes0.01%Saved less than 1% of file size.

The large savings came from structure the PDF library does not write again: a classic cross-reference table and loose objects (about a third on the text files), and the older copies of a page that a file saved again and again keeps at its end (79% on the five-times-saved file, of which a viewer shows only the last version). Two things it does not remove: the unreferenced 300,000-byte object stayed in the file, and the JPEG stored twice stayed twice. A file already packed in object streams, including one written by pdf-lib itself, came back unchanged.

On every file the page content streams, bookmarks, links, form field, XMP metadata and title were the same after compressing as before (read back with pdf-lib). What changed: the producer field became pdf-lib, a creator was added where there was none, the modification date was set, the header changed to %PDF-1.7, and the linearized file was no longer linearized. After opening, the 2,000-page file took 977 to 1,423 ms to compress and the 56 MB file 135 to 250 ms, depending on the engine.

Files it turns away

FileMessage
AES-256 with an open password, or with print and copy limits onlyThis PDF is password-protected, then Please unlock it first using our Unlock PDF tool, then try again.
The first 70% or the first 30% of the 200-page file, or 4,000 random bytes named .pdfCouldn't read this PDF file, then Please make sure it's a valid, unencrypted PDF and try again.

Chrome 156, Chromium 153, Firefox 155 and the WebKit build gave the same messages. A cut-off file was refused rather than saved with missing pages in our test.

Compressing a PDF

  1. Step 1

    Add the PDF

    The page count shows once the file is read. Encrypted files are stopped with a message.

  2. Step 2

    Compress

    pdf-lib loads the document and saves it again with object streams, which packs the file's small internal objects together.

  3. Step 3

    Compare and download

    If the new file is smaller you get it as -compressed.pdf. If not, the tool hands back your original bytes.

What this tool does not do

It does not downsample images, subset fonts, strip or remove duplicate resources. Desktop tools such as Ghostscript or Acrobat's optimizer can do those things and often get far larger savings on scanned or photo-heavy documents.

PDF Compressor FAQ

Why did my PDF hardly shrink?

This tool only repacks the file's structure. Images, fonts and page content stay as they are, and those are usually most of the size. On five older test PDFs the saving ranged from 0.3% to 22.9% in our test, and the PDF made mostly of photos gained least; a 56 MB file of scan-like pages saved 0.01%.

Does it lower image quality?

No. Pictures are not touched at all, which is why the saving is small on photo-heavy files. Compress PDF to Size is the tool that shrinks images, by turning pages into JPEG pictures.

Is the text still selectable after compressing?

Yes. Text, links, bookmarks and form fields stay as they were, because no page is redrawn. Only the way objects are stored in the file changes.

What does already well-optimized mean?

The repacked file came out the same size or bigger, so the tool gives you your original file back unchanged instead of a larger one.

Can it compress a password-protected PDF?

No. The PDF library cannot read an encrypted file, so the tool asks you to remove the password first with Unlock PDF, which needs the password.

Does anything else in the file change?

The document information is updated by the PDF library: the producer field becomes pdf-lib, a creator is added if there was none, and the modification date becomes the time you compressed it. The header also changed to %PDF-1.7 and a linearized (fast web view) file lost its linearization. A digital signature in the original stops validating, because the whole file is written again (signed files were not tested).

Why did a PDF that was edited many times shrink so much?

A PDF can be saved as an incremental update: the PDF specification (ISO 32000-1:2008, section 7.5.6) says changes "shall be appended to the end of the file, leaving its original contents intact". The PDF library writes only the current version of each object. A 12-page file saved five more times with a new version of page 1 each time went from 309,805 to 65,535 bytes, and its pages read the same afterwards.

Does it remove duplicate images or unused data?

No. The same JPEG stored twice stayed twice (the file came back unchanged), and a 300,000-byte object that nothing in the file pointed to was still in the output, which was only 1.0% smaller.

What does Saved less than 1% of file size mean?

The repacked file was smaller, but by under half a percent, which rounds to 0%. You get the repacked file, not the original. In Chrome 156 a 56 MB scan-like file shrank by 7,971 bytes and the 3-page photo file by 913 bytes, and all four engines we ran showed this message for both.

Can it repair or compress a damaged PDF?

No. A 200-page file cut off at 70% or at 30% of its length got the message Couldn't read this PDF file, the same as random bytes named .pdf, and no file was produced.

Related guide

How to compress, merge and convert PDFs without uploading them. The guide compares what lossless repacking saves on text PDFs and on photo pages, and where lossy compression has to take over.

Related Tools