What is .load_and_split()?
.load_and_split() is a convenience method on LangChain document loaders that combines loading and chunking into a single call. Internally it calls self.load() to get the full list of Documents, then passes them through the provided text splitter's .split_documents() method. The result is a flat List[Document] where each item is a chunk of the original source with the parent's metadata copied to every chunk.
The method exists primarily to reduce boilerplate in quick prototypes and notebooks. The alternative — calling loader.load() then splitter.split_documents(docs) separately — gives you the same result with an extra variable but also gives you a chance to inspect or filter the raw documents before splitting. For anything beyond a quick script, the explicit two-step approach is preferred because it separates concerns and is easier to debug.
The text_splitter argument is required. If you call load_and_split() without an argument, it falls back to a default CharacterTextSplitter with chunk_size=4000, which is rarely what you want for production RAG. Always pass a configured RecursiveCharacterTextSplitter or domain-specific splitter. Since load_and_split() calls load() internally, it inherits the same memory constraint: all documents are loaded into memory before splitting begins. For very large corpora, prefer lazy_load() combined with explicit split calls to keep memory usage bounded.
Use Cases
- • Load and chunk docs
- • RAG preparation
- • Embedding chunking
- • One-line processing
- • Pipeline simplification
- • Quick setup
Key Features
- ✓ Combined operation
- ✓ Text splitter support
- ✓ Convenience method
- ✓ Document objects
- ✓ Metadata preservation
- ✓ Simple pipeline
When NOT to Use
When you need separate steps for flexibility.
Notes
Default splitter has chunk_size=4000 — usually too large for RAG
Calling load_and_split() without a text_splitter argument uses CharacterTextSplitter(chunk_size=4000, separator="\n\n"). For most embedding models with 512-token context windows, 4000 characters is already at the limit. Always pass an explicitly configured splitter.
Metadata from the loader is copied to every chunk
If the loader sets {"source": "report.pdf", "page": 3} on a Document, every chunk produced from that document carries the same metadata dict. This is useful for citation tracking — you can show users which page a retrieved chunk came from.
Loads all documents into memory before splitting
load_and_split() calls load() internally, so the full document set is in memory before any splitting starts. For large corpora (thousands of files, large PDFs), this can exhaust available RAM. Use lazy_load() combined with splitter.split_documents([doc]) inside the loop for constant memory usage.
No async variant exists
There is no aload_and_split(). If you need async loading and splitting, await loader.aload() then call splitter.split_documents(docs) synchronously, or wrap the whole operation in asyncio.to_thread().
Method Signature
chunks = loader.load_and_split(text_splitter)
Parameters
| Parameter | Type | Required | Purpose |
|---|---|---|---|
| text_splitter | TextSplitter | Yes | Splitter to use |
Return Value
Type:
List[Document]
Description:
Split documents
Example Output:
[Document(...), Document(...), ...]
Code Examples
Load and split in one step
from langchain_text_splitters import RecursiveCharacterTextSplitter
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
chunks = loader.load_and_split(splitter)
print(f"{len(chunks)} chunks ready to embed")
PDF to vector store in four lines
from langchain_community.document_loaders import PyPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import Chroma
loader = PyPDFLoader('handbook.pdf')
splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=150)
chunks = loader.load_and_split(splitter)
db = Chroma.from_documents(chunks, OpenAIEmbeddings())
Two-step equivalent for debugging
# Equivalent explicit two-step approach — easier to debug
docs = loader.load()
print(f"{len(docs)} raw documents")
chunks = splitter.split_documents(docs)
print(f"{len(chunks)} chunks after splitting")
Common Mistakes
❌ load_and_split() without passing splitter
✅ loader.load_and_split(splitter)
Related LangChain References
Browse the full LangChain API reference index to explore more classes, methods, and decorators, or start with the LangChain introduction tutorial for end-to-end context on building with .load_and_split() and the wider framework.
.load_and_split() FAQ
What does .load_and_split() do in LangChain?
Load documents and split into chunks. .load_and_split() is a convenience method on LangChain document loaders that combines loading and chunking into a single call. Internally it calls self.load() to get the full list of Documents, then passes them through the provided text splitter's .split_documents() method. The result is a flat List[Document] where each item is a chunk of the original source with the parent's metadata copied to every chunk. The method exists primarily to reduce boilerplate in quick prototype…
Which LangChain classes support .load_and_split()?
.load_and_split() is available on Document loaders. Pin your installed LangChain version and verify the method exists in that release before deploying.
When should I use .load_and_split()?
Use .load_and_split() when your LangChain chains, agents, or pipelines need the behavior described in this guide.
What does .load_and_split() return?
.load_and_split() returns a List[Document]. Split documents
Does .load_and_split() have an async equivalent?
.load_and_split() does not have a documented async variant. Avoid .load_and_split() When you need separate steps for flexibility.
Where can I explore more LangChain API reference pages?
Open the LangChain API reference index on DevShelfHub to browse classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.