---
title: "JavaScript PDF to text: Extract text from PDF in JavaScript | Nutrient"
canonical_url: "https://www.nutrient.io/guides/web/features/text-extraction/"
md_url: "https://www.nutrient.io/guides/web/features/text-extraction.md"
last_updated: "2026-05-30T02:20:01.393Z"
description: "Discover effective methods for text extraction to streamline your workflow. Learn tips and tools for efficient data extraction and management."
---

# Extract text from PDFs using JavaScript

Extracting text from a PDF can be a complex task, so we offer several abstractions to make this simpler. In a PDF, text usually consists of glyphs that are absolutely positioned. Nutrient heuristically splits these glyphs up into words and blocks of text. Our user interface leverages this information to allow users to select and annotate text. You can read more about this in our [text selection](https://www.nutrient.io/../../features/text-selection/) guide.

Use `textLinesForPageIndex` to extract the text from a given PDF page index:

```js

const lines = await instance.textLinesForPageIndex(0);

```

For Server-based deployment, use the [`/pages/:page_index/text` endpoint][] to fetch all text contained in a page.
---

## Related pages

- [JavaScript PDF extraction library](/guides/web/extraction.md)
- [Extract pages from PDFs using JavaScript](/guides/web/extraction/page-extraction.md)
- [Read text from PDFs using JavaScript](/guides/web/extraction/read-text.md)
- [JavaScript PDF parser library](/guides/web/extraction/parse-content.md)
- [Extract selected text from PDFs programmatically](/guides/web/features/text-selection.md)

