Skip to main content
PPDF123

Repair a Corrupted PDF

Repair PDF rewrites a damaged PDF with qpdf, rebuilding its cross-reference table so the file can open again. It recovers what qpdf can still read; it cannot bring back missing images or destroyed data.

Drag and drop files here, or click to choose

Accepts PDF · up to 500.0 MB per file · up to 20 files at once

You can also paste a file with Ctrl/Cmd+V, or from the clipboard menu.

Repair re-reads the file and rewrites it with qpdf (`qpdf input -- output`). That rewrite rebuilds the xref and can recover files qpdf still parses. It is not a forensic reconstructor for burnt streams, missing images, or DRM.

There are no options. If qpdf cannot read the file, the job fails. Password-protected files are unlocked for you on this page once you enter the password (API callers run Unlock first); Repair is not a password cracker.

A file that already opens may come back slightly different at the object level and look the same on screen.

If you only needed smaller streams, Compress is the explicit packing tool. If annotations must become page content, Flatten.

The practical question is whether the file opens at all. If a viewer shows a blank window, a "file is damaged" notice, or stops partway through, the cross-reference table (the index that tells a reader where each object sits in the file) is the usual suspect, and rewriting that index is exactly what qpdf does. If the file opens but looks wrong, for example missing fonts or garbled text, the problem is in the content itself and a structural rewrite will not change it.

The result is a new file named after your upload with a `.pdf` extension. Your original is never modified, so you can always compare the two. A rewrite that succeeds proves only that qpdf could parse and write the document; it does not guarantee that every page renders, so open the result and page through it before you delete the original.

Features

  • qpdf rewrite with no extra flags
  • Fixes some xref/structure issues qpdf can parse
  • Not a content reconstructor
  • Anonymous API at /api/v1/misc/repair

When to use this tool

  • Rebuild xref on an export another tool wrote poorly
  • Try qpdf before giving up on a slightly damaged file
  • Normalize structure before Merge
  • Rescue a PDF that a mail gateway or file-sync client rewrote badly, where only the index was damaged
  • Produce a clean copy of a file that opens in a browser but is rejected by a stricter desktop reader
  • Retry an export from an old or unusual generator before asking the sender for a new copy

How do I repair a corrupted PDF?

  1. Upload a PDF that a local qpdf might still open.
  2. Click Process. There are no repair levels.
  3. Download the rewritten PDF.
  4. Open it. If qpdf failed, the original is still the one on your disk.
  5. Scroll to the last page of the result, not only the first. Damage near the end of a file is the most common kind, and a rewrite that opens on page 1 can still be missing the tail.
  6. If the page count is lower than you expected, stop and re-download or re-export the source rather than trusting the shortened copy.

Limits and edge cases

  • No deep object reconstruction
  • A successful rewrite does not guarantee every page renders; check the output
  • Image or font data that is missing from the file cannot be recreated
  • No log of what was fixed is returned, only the new file
  • Not Unlock
  • qpdf-unreadable files fail
  • Upload limit on this website: 500 MB per file, sent in chunks above about 95 MB. A single direct API request body is capped at 100 MB.

Test results and conditions

  • Test file: a 3-page, 50 KB statement PDF (90 transactions) generated for this project's test suite, damaged in five ways and sent through Repair.
  • The index pointed to the wrong byte offset: returned as a 3-page file with all 90 transactions readable.
  • Three junk lines in front of the %PDF header: returned as a 3-page file with all text intact.
  • 200 bytes in the middle of the file overwritten with zeros: returned as a 3-page file with all 90 transactions still readable.
  • The last 300 bytes cut off: rejected with an invalid_pdf error and no file, because qpdf could not find the document's trailer.
  • The file cut at 60 percent, like an interrupted download: rejected the same way. Repair never returns a half-finished file, so download it again.
  • A text file renamed to .pdf: rejected with invalid_pdf.

Examples

  • A PDF with a messy xref that qpdf still reads often opens after Repair
  • A file cut off mid-stream usually errors
  • A 40-page export whose index points to the wrong byte offsets: a viewer reports damage, Repair returns a 40-page file that opens normally
  • A download that stopped at 60 percent: Repair either fails outright or returns a shorter file, and the right next step is to download it again
  • A scanned file with one unreadable page image: the structure may be fixed, but that page will still look blank or broken

Privacy for this tool

Files are uploaded over HTTPS, processed in memory or a short-lived temporary directory on our servers, and deleted when your result is ready. We do not keep copies for later browsing, training, or advertising profiles. See the Privacy Policy for retention details and AdSense cookie disclosures.

Frequently asked questions

Can a corrupted PDF be fixed?
It depends on the damage. In our test on a 5-page file, Repair restored all 5 pages and their text when the startxref pointer was wrong, when the cross-reference entries were shifted, when the trailer was cut off and when the header was garbled. It could not restore a file cut short: with the last fifth removed it kept 5 pages but only 4 had their text. Damaged page data came back with errors and one page whose text differed, and a damaged encrypted file was rejected with invalid_pdf.
My PDF opens in a browser but not in Acrobat. Should I run Repair?
Yes, that is a good fit. Browsers are often more forgiving than desktop readers about a broken index, and a qpdf rewrite normalizes the structure so stricter readers accept it. If the rewrite still will not open, the damage is inside the content streams.
What does a failure look like?
The job returns an error instead of a file. That means qpdf could not parse the document well enough to write it. Try downloading the original again, re-exporting from the source application, or opening it in the program that created it and saving a fresh copy.
Will the file size change?
It can go up or down slightly because the objects are written out again. Repair does not recompress images, so do not expect a big reduction. Use Compress when size is the goal.
Can I run Repair on a file that already works?
You can, and you get a structurally tidy copy. Nothing about the visible pages should differ. It is a reasonable normalizing step before Merge or Split if one of your inputs has caused errors there.
Will Repair recover pages that were cut off?
No. Pages whose data is missing from the file stay missing. Repair can only rewrite what is still readable.
Will this restore a truncated download?
Only if qpdf can still parse it. Many truncated files fail outright.
Does Repair decrypt?
Only for files that open without a password (owner-password restrictions): those come back without encryption. A file that needs a password to open is rejected; use Unlock with a password you are entitled to use.
Is this the same as Compress?
No. Repair is a bare qpdf rewrite. Compress adds stream and object-stream flags.
Will text change?
Not as a rewrite of words. Object numbers and offsets usually change.

Last updated:

Call this from code

Every tool on this site is a plain REST endpoint - no account or API key needed for anonymous use. Built for AI agents and developers as much as for browsers.

curl -X POST "https://pdf123.xyz/api/v1/misc/repair" \
  -F "[email protected]" \
  -o output.pdf

Also available as an MCP tool for agent clients that speak Model Context Protocol (JSON-RPC 2.0 over POST /mcp). Full API reference

Use it from an AI agent

Skill

Claude Code, Codex, Cursor and other AI agents can run Repair PDF for you with this skill: /skills/pdf123-repair.md

All agent skills

Files are used only for this processing job and deleted automatically afterward.