POST
/api/v1/pdf/splitSplit PDF
Split a PDF into multiple files using one of three modes: extract every page individually, specify custom page ranges, or divide into fixed-size chunks. The result is a ZIP archive containing all split files.
Content-Type: multipart/form-data
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
file | file | Required | - | The PDF file to split. |
split_mode | string | Required | - | Split strategy. One of: all-pages, page-ranges, chunks. |
page_ranges | string | Conditional | - | Required when split_mode=page-ranges. Comma-separated ranges, e.g. 1-3,5,7-9. Each range produces one PDF. |
chunk_size | integer | Conditional | - | Required when split_mode=chunks. Number of pages per chunk. |
Split Modes
all-pages— Extracts every page as a separate single-page PDF.page-ranges— Creates one PDF per specified range. Usepage_rangesparameter.chunks— Divides the document into equal chunks ofchunk_sizepages. The last chunk may contain fewer pages.
Code Examples
cURL
bash
# Split by page ranges
curl -X POST "https://app.alternapdf.com/api/v1/pdf/split" \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "split_mode=page-ranges" \
-F "page_ranges=1-3,5,7-9" \
--output split_pages.zip
# Split every page
curl -X POST "https://app.alternapdf.com/api/v1/pdf/split" \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "split_mode=all-pages" \
--output all_pages.zip
# Split into chunks of 10 pages
curl -X POST "https://app.alternapdf.com/api/v1/pdf/split" \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "split_mode=chunks" \
-F "chunk_size=10" \
--output chunks.zipPython
python
import requests
url = "https://app.alternapdf.com/api/v1/pdf/split"
headers = {"X-API-Key": "YOUR_API_KEY"}
files = {
"file": ("document.pdf", open("document.pdf", "rb"), "application/pdf"),
}
data = {
"split_mode": "page-ranges",
"page_ranges": "1-3,5,7-9",
}
response = requests.post(url, headers=headers, files=files, data=data)
with open("split_pages.zip", "wb") as f:
f.write(response.content)
print(f"ZIP archive saved ({len(response.content)} bytes)")JavaScript
javascript
const fs = require("fs");
const FormData = require("form-data");
const axios = require("axios");
const form = new FormData();
form.append("file", fs.createReadStream("document.pdf"));
form.append("split_mode", "page-ranges");
form.append("page_ranges", "1-3,5,7-9");
const response = await axios.post(
"https://app.alternapdf.com/api/v1/pdf/split",
form,
{
headers: {
"X-API-Key": "YOUR_API_KEY",
...form.getHeaders(),
},
responseType: "arraybuffer",
}
);
fs.writeFileSync("split_pages.zip", response.data);
console.log(`ZIP archive saved (${response.data.byteLength} bytes)`);Response
200ZIP archive containing split PDFs
| Header | Value |
|---|---|
Content-Type | application/zip |
Content-Disposition | attachment; filename="split_pages.zip" |
The response body contains a ZIP archive with the split PDF files. Each file is named based on the split mode and page numbers. On error, a JSON object with a detail field is returned instead.