*   [](/v0.2/)
*   [How-to guides](/v0.2/docs/how_to/)
*   How to load data from a directory

How to load data from a directory
=================================

This covers how to load all documents in a directory.

The second argument is a map of file extensions to loader factories. Each file will be passed to the matching loader, and the resulting documents will be concatenated together.

Example folder:

    src/document_loaders/example_data/example/├── example.json├── example.jsonl├── example.txt└── example.csv

Example code:

    import { DirectoryLoader } from "langchain/document_loaders/fs/directory";import {  JSONLoader,  JSONLinesLoader,} from "langchain/document_loaders/fs/json";import { TextLoader } from "langchain/document_loaders/fs/text";import { CSVLoader } from "@langchain/community/document_loaders/fs/csv";const loader = new DirectoryLoader(  "src/document_loaders/example_data/example",  {    ".json": (path) => new JSONLoader(path, "/texts"),    ".jsonl": (path) => new JSONLinesLoader(path, "/html"),    ".txt": (path) => new TextLoader(path),    ".csv": (path) => new CSVLoader(path, "text"),  });const docs = await loader.load();console.log({ docs });

* * *

#### Was this page helpful?

  

#### You can also leave detailed feedback [on GitHub](https://github.com/langchain-ai/langchainjs/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E).

[

Previous

How to write a custom document loader

](/v0.2/docs/how_to/document_loader_custom)[

Next

How to load HTML

](/v0.2/docs/how_to/document_loader_html)