🛠️

PDF Compressor

Reduce PDF file size by removing duplicate objects and compressing streams

POST 10 credits /v1/pdf/compress
curl -X POST "https://pdf.toolkitapi.io/v1/pdf/compress" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://toolkitapi.io/large-report.pdf"}'
import httpx

resp = httpx.post(
    "https://pdf.toolkitapi.io/v1/pdf/compress",
    json={"url": "https://toolkitapi.io/large-report.pdf"},
)
print(resp.json())
const resp = await fetch("https://pdf.toolkitapi.io/v1/pdf/compress", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"url": "https://toolkitapi.io/large-report.pdf"}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "pdf": "JVBERi0xLjcKMSAwIG9iago8...",
  "original_size": 5242880,
  "compressed_size": 2097152,
  "savings_percent": 60.0,
  "page_count": 45
}

Description

Reduce PDF file size by removing duplicate objects and compressing streams

How to Use

1

1. Provide the PDF via `pdf` (base64) or `url` (public URL).

2

2. The endpoint automatically applies compression — no configuration needed.

3

3. Check `savings_percent` in the response to see how much the file shrank.

4

4. Use the returned `pdf` (base64) as your optimized version.

About This Tool

PDF Compressor reduces the file size of PDF documents by removing duplicate internal objects, eliminating orphaned data, and compressing content streams. It's a lossless optimization — the visual content remains identical, but the file takes up less space.

Use this tool before distributing large PDFs via email, uploading to storage with size limits, or serving documents over bandwidth-constrained connections. The response includes both the original and compressed sizes along with the percentage savings.

Documents with redundant embedded objects, uncompressed streams, or bloated metadata benefit the most. Already-optimized PDFs may see minimal reduction.

Why Use This Tool

Frequently Asked Questions

Is the compression lossless?
Yes. The compressor removes duplicate objects and compresses content streams without altering visual content. Text, images, and layout remain unchanged.
Why is the savings percentage low for my file?
PDFs that were already optimized by their creator (e.g. exported from modern tools with compression enabled) have less room for improvement. Older or poorly-generated PDFs typically see the biggest reductions.
Does this reduce image quality?
No. Image data within the PDF is not re-encoded or downsampled. The optimization targets structural redundancy, not image quality.

Start using PDF Compressor now

Get your free API key and make your first request in under a minute.