Get started

How to merge PDF files: 5 free methods

Merge multiple PDF files into one document for free. Compare 5 methods including browser-based tools, command-line, and programmatic approaches.

benoitdedDecember 24, 20255 min read

Need to combine multiple PDFs into one? Whether it's invoices for accounting, chapters of a report, or scanned documents, merging PDFs is something most people need to do regularly. Here are five free ways to do it.

Method 1: Browser-based tool (fastest)

The simplest approach: drag and drop your files into a browser-based merger. No software to install, no account required.

How to merge with PDF4.dev:

  1. Go to Merge PDF
  2. Drag your PDF files onto the upload area (or click to browse)
  3. Reorder files by dragging them if needed
  4. Click "Merge PDFs"
  5. Download your combined file

Why this is our recommended method:

  • Files never leave your browser, 100% private
  • No file size limits
  • No watermarks or signup required
  • Works on any device with a modern browser

Method 2: macOS Preview

If you're on a Mac, Preview can merge PDFs without any third-party tools.

  1. Open the first PDF in Preview
  2. Go to View → Thumbnails to show the sidebar
  3. Drag additional PDF files into the thumbnail sidebar at the desired position
  4. Go to File → Export as PDF to save the merged document

Limitations:

  • macOS only
  • Can be slow with large files
  • The interface can be confusing, make sure you export, not just save

Method 3: Command line (pdftk or qpdf)

For power users and automation, command-line tools are the way to go.

Using pdftk

pdftk file1.pdf file2.pdf file3.pdf cat output merged.pdf

Using qpdf

qpdf --empty --pages file1.pdf file2.pdf file3.pdf -- merged.pdf

Using Ghostscript

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite \
   -sOutputFile=merged.pdf file1.pdf file2.pdf file3.pdf

When to use this:

  • Automating merges in scripts or CI/CD
  • Processing many files in batch
  • When you need precise control over page ranges

Method 4: Python script

For developers who need to merge PDFs programmatically:

from PyPDF2 import PdfMerger
 
merger = PdfMerger()
 
files = ['report.pdf', 'appendix-a.pdf', 'appendix-b.pdf']
for pdf in files:
    merger.append(pdf)
 
merger.write('combined-report.pdf')
merger.close()

Or with pdf-lib in Node.js:

import { PDFDocument } from 'pdf-lib';
import fs from 'fs';
 
async function merge(files) {
  const merged = await PDFDocument.create();
 
  for (const file of files) {
    const bytes = fs.readFileSync(file);
    const pdf = await PDFDocument.load(bytes);
    const pages = await merged.copyPages(pdf, pdf.getPageIndices());
    pages.forEach(page => merged.addPage(page));
  }
 
  const output = await merged.save();
  fs.writeFileSync('merged.pdf', output);
}
 
merge(['file1.pdf', 'file2.pdf', 'file3.pdf']);

When merging is the wrong solution

Manual merging, whether with a browser tool, Preview, or a script, works fine for one-off tasks. But if you're producing merged documents repeatedly, like "invoice + terms" or "report + appendix" for every customer, post-processing is the wrong layer to solve this.

The better approach: design a single template that includes all sections from the start.

curl -X POST https://pdf4.dev/api/v1/render \
  -H "Authorization: Bearer p4_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "invoice-with-terms",
    "data": {
      "company": "Acme Corp",
      "invoice_number": "INV-001"
    }
  }'

One API call, one PDF with all sections, no merge step. Each section is a block of HTML in the template, separated by page-break-before: always. Dynamic content (invoice data) gets injected via Handlebars variables. Static sections (terms, footer boilerplate) are hardcoded in the template.

This eliminates the merge step entirely, which means fewer moving parts, no intermediate files, and no risk of page ordering bugs.

PDF4.dev has a free tier. Create a template and generate your first combined document in minutes.

Comparing the methods

MethodSpeedPrivacyAutomationSetup
Browser toolInstantFiles stay localManualNone
macOS PreviewFastLocalManualNone (Mac only)
Command lineFastLocalYesInstall tool
Python/Node.jsFastLocalYesInstall deps
Generate via API~300msProcessed server-sideYesAPI key

Tips for better merges

Watch the file size

Merging 10 image-heavy PDFs can create a massive file. Consider compressing the result afterward.

Check page sizes

Mixing A4 and Letter documents creates a PDF with inconsistent page sizes. This is technically valid but may cause printing issues. Standardize page sizes before merging if this matters.

Preserve bookmarks

Most merge tools don't preserve bookmarks from individual files. If you need bookmarks in the final document, add them after merging with a tool like pdftk.

Order matters

Files are merged in the order you add them. Double-check the sequence before processing, it's easier to reorder before merging than to split and re-merge afterward.

FAQ

Can I merge password-protected PDFs?

Yes, but you need to unlock them first. Most merge tools can't read encrypted PDFs without the password.

Is there a limit to how many PDFs I can merge?

With browser-based tools, the limit is your device's memory. For typical documents, merging 50-100 files is fine. For very large merges (1000+ files), use a command-line tool.

Will merging reduce quality?

No. PDF merging copies pages as-is, fonts, images, and vectors are preserved at their original quality. The only exception is if you compress the merged result afterward.

Can I merge specific pages from different PDFs?

Yes, first split the pages you need from each PDF, then merge the extracted pages together.

Free tools mentioned:

Merge PdfTry it free

Start generating PDFs

Build PDF templates with a visual editor. Render them via API from any language in ~300ms.