Skip to main content

Document loaders


Head to Integrations for documentation on built-in integrations with document loader providers.

Use document loaders to load data from a source as Document's. A Document is a piece of text and associated metadata. For example, there are document loaders for loading a simple .txt file, for loading the text contents of any web page, or even for loading a transcript of a YouTube video.

Document loaders expose a "load" method for loading data as documents from a configured source. They optionally implement a "lazy load" as well for lazily loading data into memory.

Get started

The simplest loader reads in a file as text and places it all into one Document.

import { TextLoader } from "langchain/document_loaders/fs/text";

const loader = new TextLoader("src/document_loaders/example_data/example.txt");
const docs = await loader.load();

API Reference:

  • TextLoader from langchain/document_loaders/fs/text

Help us out by providing feedback on this documentation page: