> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TextLoader integration

> Integrate with the TextLoader document loader using LangChain JavaScript.

<Tip>
  **Compatibility**: Only available on Node.js.
</Tip>

This notebook provides a quick overview for getting started with `TextLoader` [document loaders](/oss/javascript/integrations/document_loaders). For detailed documentation of all `TextLoader` features and configurations head to the [API reference](https://reference.langchain.com/javascript/langchain-core/document_loaders/base/BaseDocumentLoader).

## Overview

### Integration details

| Class                                                                                                              | Package                                              | Compatibility | Local | PY support |
| :----------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------- | :-----------: | :---: | :--------: |
| [`TextLoader`](https://reference.langchain.com/javascript/langchain-core/document_loaders/base/BaseDocumentLoader) | [langchain](https://www.npmjs.com/package/langchain) |   Node-only   |   ✅   |      ❌     |

## Setup

To access `TextLoader` document loader you'll need to install the `langchain` package.

### Installation

The LangChain TextLoader integration lives in the `langchain` package:

<CodeGroup>
  ```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  npm install langchain
  ```

  ```bash yarn theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  yarn add langchain
  ```

  ```bash pnpm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  pnpm add langchain
  ```
</CodeGroup>

## Instantiation

Now we can instantiate our model object and load documents:

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { TextLoader } from "@langchain/classic/document_loaders/fs/text"

const loader = new TextLoader("../../../../../../examples/src/document_loaders/example_data/example.txt")
```

## Load

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
const docs = await loader.load()
docs[0]
```

```javascript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
Document {
  pageContent: 'Foo\nBar\nBaz\n\n',
  metadata: {
    source: '../../../../../../examples/src/document_loaders/example_data/example.txt'
  },
  id: undefined
}
```

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
console.log(docs[0].metadata)
```

```javascript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
{
  source: '../../../../../../examples/src/document_loaders/example_data/example.txt'
}
```

***

## API reference

For detailed documentation of all `TextLoader` features and configurations head to the [API reference](https://reference.langchain.com/javascript/langchain-core/document_loaders/base/BaseDocumentLoader).

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/document_loaders/file_loaders/text.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
