---
title: "JavaScript library to split PDFs | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/editor/split/"
md_url: "https://www.nutrient.io/guides/web/editor/split.md"
last_updated: "2026-05-15T19:10:05.080Z"
description: "Split PDFs into multiple documents using JavaScript with Nutrient Web SDK. Load documents in headless mode and use removePages to create separate files programmatically."
---

# Split PDFs using JavaScript

To split a PDF into one or more separate documents, use the headless editing and remove pages operations.

In this example, you’ll be splitting a 10-page document into 2 separate 5-page documents.

For each new document, load the original document in headless mode:

```js

const instanceA = await NutrientViewer.load({
  document: document,
  headless: true
});

const instanceB = await NutrientViewer.load({
  document: document,
  headless: true
});

```

For each of these instances, remove the pages you don’t want for each document.

In this example, you’ll remove the last five pages from the first instance and the first five pages from the second instance, and then you’ll export the final PDF:

```js

const fileA = await instanceA.exportPDFWithOperations([
  {
    type: "removePages",
    pageIndexes: [1, 2, 3, 4, 5]
  }
]);

const fileB = await instanceB.exportPDFWithOperations([
  {
    type: "removePages",
    pageIndexes: [6, 7, 8, 9, 10]
  }
]);

```

You should now have the content of each new file as an array buffer in the above variables, which can be used however you wish.

---

## Related pages

- [Add images to PDFs using JavaScript](/guides/web/editor/add-image.md)
- [Add Bates numbering in PDFs using JavaScript](/guides/web/editor/add-bates-number.md)
- [PDF editing toolbar and UI](/guides/web/features/document-editor-ui.md)
- [Add pages to PDFs using JavaScript](/guides/web/editor/add-page.md)
- [Process documents via Document Engine or DWS API using JavaScript](/guides/web/editor/backend-processing.md)
- [Edit page labels in a PDF](/guides/web/editor/page-label.md)
- [PDF content editing API for Web](/guides/web/editor/content-editor-api.md)
- [Edit PDF text using our JavaScript content editor](/guides/web/editor/edit-text.md)
- [Merge PDF files using JavaScript](/guides/web/editor/merge-or-combine.md)
- [Headless PDF editor](/guides/web/features/document-editor.md)
- [JavaScript PDF editor library](/guides/web/editor.md)
- [Replace text in PDFs using JavaScript](/guides/web/editor/replace-text.md)

