<Tip>
**Compatibility**


Only available on Node.js.

</Tip>

This notebook provides a quick overview for getting started with TextLoader document loaders. For detailed documentation of all TextLoader features and configurations head to the API reference.

Overview

Integration details

ClassPackageCompatibilityLocalPY support
TextLoaderlangchainNode-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:
import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";
<IntegrationInstallTooltip></IntegrationInstallTooltip>

<Npm2Yarn>
  langchain
</Npm2Yarn>

Instantiation

Now we can instantiate our model object and load documents:
import { TextLoader } from "langchain/document_loaders/fs/text"

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

Load

const docs = await loader.load()
docs[0]
Document {
  pageContent: 'Foo\nBar\nBaz\n\n',
  metadata: {
    source: '../../../../../../examples/src/document_loaders/example_data/example.txt'
  },
  id: undefined
}
console.log(docs[0].metadata)
{
  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://api.js.langchain.com/classes/langchain.document_loaders_fs_text.TextLoader.html