Projects › Everyday tools › Merge PDF
Merge PDF files free, without uploading, and make your own PDF tool with AI
Drop in your PDFs, put them in order, and download one file. Or split one and keep just the pages you need. It all happens in your browser, so your files never leave your computer. Then make your own PDF tool with a free AI assistant.
No files yet. Add two or more to merge them.
Your own PDF tool, on your own computer
You'll ask a free AI assistant for a small Python script that joins PDFs together. Put files in a folder and run it, or drop files straight onto it. Then add options to split a PDF and pull out just the pages you need.
- A script that merges every PDF in a folder, in name order
- Or just the files you give it, without touching the originals
- A split option that saves every page as its own file
- A page-range option, like "pages 1-3 and 7", and a way to turn pages round
- Drag and drop: drop files onto an icon on Windows, or right-click them on a Mac
- If you'd like one, a browser version in a single HTML file, like the tool above
Good for: anyone who sends forms, receipts or scanned letters as one file, people who'd rather not upload private documents to a website, and anyone who wants a gentle first script that's useful straight away.
What you need
Build it in six steps
Step 1 gives you a simple script that works, and each step after it adds one more feature. Your script won't look like the tool at the top of this page: it's a different kind of tool that runs on your own computer.
Install Python and pypdf
Follow How to install Python first. Then ask the AI to walk you through the one add-on the script needs, pypdf, which reads and writes PDFs:
Copy this promptI've just installed Python on my [Windows / Mac] computer and I don't know how to code. In very simple steps, tell me how to: - check Python is working - install the "pypdf" add-on with pip - make a new folder called pdf-tools in my Documents folder, with a folder inside it called to-merge - open a terminal in the pdf-tools folder Tell me exactly what to type and what I should see if it worked.
Ask for the merge script
Copy this prompt into your AI assistant:
Copy this promptI don't know how to code. Please write me a Python script called merge_pdfs.py that joins PDF files into one. It's for my own files. Requirements: - ONE complete Python file using the "pypdf" add-on, which I have installed. - If I run it with no file names, it merges every PDF in the "to-merge" folder next to the script, in name order. Sort numbers the way a person would, so "2.pdf" comes before "10.pdf". - If I give it file names, it merges just those, sorted by name in the same way. - Save the result as merged.pdf next to the script. If that file already exists, use merged-2.pdf, merged-3.pdf and so on, so it never overwrites anything. - Print each file name and its page count as it goes, then the total pages and where it saved the file. - If a file is password-protected or damaged, print a clear message saying which one, skip it, and carry on. - Never change or delete the original files. Please give me the complete file in one code block, then tell me in simple steps how to save it in my pdf-tools folder and run it.
Copy the code, paste it into your text editor, and save it as merge_pdfs.py in your pdf-tools folder.
Run it
Put two or three PDFs in the to-merge folder. If the order matters, start each name with a number: 01 cover, 02 letter, 03 receipts. Open a terminal in your pdf-tools folder and type python merge_pdfs.py (on a Mac, python3 merge_pdfs.py). You should see each file and its page count, and a new merged.pdf in the folder. Open it and check the pages are all there, in the right order.
If anything looks wrong, paste what you saw straight back into the chat:
Copy this promptI ran merge_pdfs.py and got this: [paste everything the terminal printed] Please explain what it means in plain English. If something needs fixing, send me the complete fixed file.
Add split and page-range options
The same script can take PDFs apart as well. Ask for a few simple commands:
Copy this promptPlease add some options to merge_pdfs.py, keeping everything it does now: - Split: "python merge_pdfs.py split myfile.pdf" saves every page as its own PDF in a new folder named after the file, like myfile-page-01.pdf. - Pages: "python merge_pdfs.py pages myfile.pdf 1-3,7" saves just those pages, in that order, as a new file called myfile-pages.pdf. - Rotate: "python merge_pdfs.py rotate myfile.pdf 2,5 90" turns those pages a quarter turn clockwise and saves a copy called myfile-turned.pdf. - If I ask for a page that doesn't exist, tell me how many pages the file has instead of crashing. - "python merge_pdfs.py help" prints a short list of these commands with an example of each. Send me the complete updated file.
Tip: to remove a page, use the pages option and leave that page out. "1-4, 6-12" skips page 5.Make it drag and drop
Typing commands gets old. On Windows, a .bat file is a tiny file that runs commands for you: drop PDFs onto it and Windows hands it their names. On a Mac, a Quick Action adds your own item to the menu you get when you right-click files in Finder. The Shortcuts app can make one in a few clicks.
Copy this promptI'd like to merge PDFs without opening a terminal. My merge_pdfs.py is in Documents/pdf-tools on my [Windows / Mac] computer. - On Windows: write me a file called "Merge PDFs.bat" that I can keep on my desktop. When I drop PDFs onto it, it runs merge_pdfs.py on those files, using the full path to the script, and keeps the window open at the end so I can read what happened. - On a Mac: give me click-by-click steps to make a Quick Action with the Shortcuts app (or Automator, if that's simpler), so I can select PDFs in Finder, right-click, and choose Quick Actions, then Merge PDFs. Use the full path to python3 and to the script. - Update merge_pdfs.py so that when it's given files, it saves merged.pdf in the same folder as the first file. Send me the complete updated merge_pdfs.py as well.
Number your files if order matters. Windows doesn't always pass dropped files in the order you see them, which is why the script sorts them by name.Optional: a browser version in one file
Would you rather click than type? Ask for a single web page that works like the tool at the top of this page. It loads a free PDF library called pdf-lib from the internet, but your files are still only read on your own computer.
Copy this promptPlease make me a single HTML file called pdf-merge.html that merges PDFs in my browser, with no uploads. Use the pdf-lib library from a CDN (jsDelivr or unpkg), with a fixed version number. - A big area I can drag PDFs onto, plus a "Choose files" button. - Show the files as a list with their page counts, with up and down buttons to change the order and a remove button for each. - A "Merge and download" button that saves merged.pdf. - If a PDF is password-protected, say so clearly instead of failing silently. - A clean, simple design that works on a phone too. Give me the complete file in one code block, and tell me how to save it and open it.
Not sure how to save and open it? See How to save and open an HTML file.
Quick fixes
"pip is not recognised" or "command not found"
Ask Python to run pip for you instead. On Windows, type py -m pip install pypdf. On a Mac, type python3 -m pip install pypdf. If Python itself isn't recognised either, see the next fix.
"python is not recognised"
On a Mac, type python3 instead of python. On Windows, try py, or reinstall Python and tick Add python.exe to PATH. Our Install Python guide has pictures.
"No module named pypdf"
The add-on isn't installed yet, or it went into a different copy of Python. Use the -m pip commands above, which always install into the Python you're running, then try again.
It says a file is encrypted or password-protected
Some PDFs need a password to open, and some are locked against changes even though they open normally. Neither the script nor the tool at the top of this page can merge them as they are. If the file is yours and you know the password, ask the AI: "Please make merge_pdfs.py ask me for the password when a file is encrypted." It may tell you to run pip install "pypdf[crypto]" too. Only do this with files you're allowed to change.
The pages come out in the wrong order
Computers sort names letter by letter, so "10 receipt" can come before "2 letter". Start every name with two digits: 01, 02, 03 and so on. Then check the script prints the files in the order you expect.
The .bat window flashes and closes
Drop PDFs onto the .bat file rather than double-clicking it. If it still closes before you can read it, make sure the last line says pause. Then paste what the window shows into the chat.
The Quick Action doesn't appear on my Mac
Open the shortcut in the Shortcuts app, click the i (details) button, and make sure Use as Quick Action and Finder are ticked. Then right-click a PDF again. It may be inside the Quick Actions submenu.
The merged file is huge
Scanned pages are photos, so they're big. Merging doesn't make them smaller. See "Shrink big PDFs" below.
Twist it into something else
Once you have a script that opens PDFs, lots of small jobs are one prompt away. Ask the AI to add:
An expenses pack
combines a month of scanned receipts into one PDF, with the month in the file name
Page numbers
adds "Page 3 of 12" to the bottom of every page of the merged file
Shrink big PDFs
makes scanned files small enough to email, and tells you the size before and after
Photos to PDF
turns a folder of phone photos into one PDF, one photo per page
A "DRAFT" stamp
puts a light diagonal watermark across every page before you send it round
Just the signed pages
pulls out the pages you've signed from a long contract, so you send back only those
Some files shouldn't go to random websites
Online PDF sites are handy, but every file you merge there is uploaded to someone else's computer. Most say they delete files after an hour or two. You have to take their word for it. That's fine for a takeaway menu. It's less fine for a contract, a payslip, a bank statement or a letter from your doctor. Your own script runs on your computer, works without the internet, has no daily limits or watermarks, and never asks you to sign up. It's also a gentle first script: once you've made one thing that tidies up files for you, you'll spot lots of other jobs it could do.