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 Lossless. Compression that can be undone exactly: the decoded file has the same pixels or bytes as the original. PNG and the plain 'repack' step of a PDF compressor are lossless, so the saving is limited to what repetition and structure allow. Read the guide 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 PDF | Before | After | Saving |
|---|---|---|---|
| 2-page report made with ReportLab | 2,853 bytes | 2,201 bytes | 22.9% |
| 1 page printed to PDF from Chrome | 19,502 bytes | 16,940 bytes | 13.1% |
| 1 page from the macOS print system | 12,908 bytes | 12,332 bytes | 4.5% |
| 5 pages of uncompressed text | 30,577 bytes | 29,359 bytes | 4.0% |
| 3 pages, one photo each | 360,494 bytes | 359,581 bytes | 0.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
- A hard limit such as 1 MB for an upload portal: Compress PDF to Size turns pages into JPEG images at falling resolution until the file fits. Text is no longer selectable afterwards.
- Only some pages matter: remove the rest with PDF Page Remover or keep a range with PDF Split.
- Large photos inside: extract them with Extract Images from PDF, shrink them with Image Compressor and rebuild the PDF.
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 PDF | Before | After | Saving | Message |
|---|---|---|---|---|
| 12 text pages, classic cross-reference table, compressed page streams | 8,974 bytes | 5,859 bytes | 34.7% | Saved 35% of file size! |
| The same 12 pages with page streams stored uncompressed | 46,721 bytes | 43,620 bytes | 6.6% | Saved 7% of file size! |
| The same 12 pages already packed in object streams | 5,653 bytes | 5,653 bytes (original returned) | 0% | Your PDF was already well-optimized! |
| The same 12 pages saved linearized (fast web view) | 9,551 bytes | 6,062 bytes | 36.5% | Saved 37% of file size! |
| 200 text pages | 142,353 bytes | 86,751 bytes | 39.1% | Saved 39% of file size! |
| 12 pages saved again five times, each time with a new 60,000-byte version of page 1 appended | 309,805 bytes | 65,535 bytes | 78.9% | Saved 79% of file size! |
| 12 pages plus a 300,000-byte object that nothing in the file refers to | 309,140 bytes | 305,926 bytes | 1.0% | Saved 1% of file size! |
| The same 585,945-byte JPEG stored twice, once per page | 1,173,175 bytes | 1,173,175 bytes (original returned) | 0% | Your PDF was already well-optimized! |
| 2,000 text pages written by pdf-lib | 2,136,611 bytes | 2,136,611 bytes (original returned) | 0% | Your PDF was already well-optimized! |
| 40 scan-like JPEG pages (Pillow) | 56,183,134 bytes | 56,175,163 bytes | 0.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
| File | Message |
|---|---|
| AES-256 with an open password, or with print and copy limits only | This 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 .pdf | Couldn'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
Step 1
Add the PDF
The page count shows once the file is read. Encrypted files are stopped with a message.
Step 2
Compress
pdf-lib loads the document and saves it again with object streams, which packs the file's small internal objects together.
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 Metadata. Information stored in a file about the file: in a PDF, fields such as title, author, the program that made it and the creation date; in a photo, the camera settings and capture time. It travels with the file unless something removes it. Read the guide 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.