Overview
This versatile loader uses LangChain’sTextLoader to read text content from files. It supports a wide range of text-based file formats, making it ideal for loading documentation, code, configuration files, and other text content.
Supported File Types
The Text File Loader supports an extensive list of file formats:- Documentation
- Programming
- Web & Styling
- Configuration
.txt- Plain text files.md/.markdown- Markdown files.html- HTML documents.xml- XML documents.rst- reStructuredText.tex/.ltx- LaTeX documents
Configuration
The text file(s) to load. Supports multiple file upload.Supported Extensions: See the comprehensive list above
Optional text splitter to chunk the file content into smaller segments.
Recommended for large files or when processing with LLMs that have context limits.
Advanced Parameters
Additional metadata to attach to the extracted documents.
Comma-separated list of metadata keys to exclude from the output.Example:
source, blobTypeSpecial value: Use * to omit all default metadata and only include your custom metadata.Output
The Text File Loader provides two output formats:- Document
- Text
Returns an array of document objects containing the file content and metadata.
Usage Examples
Loading a Single Text File
Upload File
Click the file input and select your text file (e.g., README.md, config.json, script.py).
Optional: Add Text Splitter
For large files, connect a text splitter to chunk the content appropriately.
Loading Multiple Files
Loading Code Files
With Custom Metadata
- Organizing loaded documents
- Filtering during retrieval
- Tracking document sources
- Version control integration
Common Use Cases
Code Documentation
Load README files and documentation for AI-assisted code exploration
Knowledge Base
Import markdown documentation into searchable knowledge bases
Configuration Analysis
Load and analyze configuration files (JSON, YAML, XML)
Content Processing
Process text content for summarization, analysis, or transformation
Specific Scenarios
Loading Documentation Site
Loading Documentation Site
Scenario: Load all markdown files from a documentation repositorySteps:
- Upload all
.mdfiles from your docs folder - Add metadata to tag documentation sections
- Use a text splitter to create searchable chunks
- Store in a vector database for semantic search
- Build a Q&A chatbot over your documentation
Code Repository Indexing
Code Repository Indexing
Scenario: Index source code for AI-assisted developmentSteps:
- Load code files (
.js,.ts,.py, etc.) - Add metadata for file paths and modules
- Use code-aware text splitters
- Enable developers to ask questions about the codebase
Multi-language Content
Multi-language Content
Scenario: Load translated documentation in multiple languagesSteps:
- Upload files for each language
- Add
languagefield to metadata - Use language-specific text splitters if available
- Enable language-filtered retrieval
File Storage Reference
The Text File Loader supports both direct file uploads and file storage references:- Direct Upload
- File Storage
Files are uploaded directly through the UI and converted to base64.
Best Practices
Recommended Practices
- Use Text Splitters: Always use text splitters for files larger than a few hundred lines
- Add Metadata: Include source information for better retrieval and debugging
- Encoding: Ensure files are UTF-8 encoded to avoid character issues
- Organization: Use consistent naming conventions for uploaded files
Troubleshooting
Garbled or corrupted text
Garbled or corrupted text
Cause: File encoding is not UTF-8Solution: Convert your file to UTF-8 encoding before uploading:
File too large to process
File too large to process
Cause: File exceeds memory limitsSolutions:
- Split the file into smaller chunks before uploading
- Use a more aggressive text splitter configuration
- Process the file in batches
Unsupported file type
Unsupported file type
Cause: File extension not in the supported listSolutions:
- Rename the file to a supported extension if it’s text-based
- Convert the file to a supported format
- Use a different, more appropriate loader (e.g., PDF loader for PDFs)
Performance Tips
Related Resources
File Loader
Generic loader for multiple file types
Vector Stores
Store text content for semantic search
Document Loaders
Explore all document loader options