Upload Files as Text
Attach supported files and let LibreChat route or extract their content automatically.
Upload Files as Text
Ever wanted to hand a PDF, a code file, or a spreadsheet to the AI and just say "read this"? LibreChat's unified uploader routes the file to the provider or extracts its text automatically based on its type and the selected endpoint.
You attach a file, LibreChat extracts the text from it, and the full content gets pasted straight into your conversation. The AI can then read every word of it ā no plugins, no vector databases, no extra services to configure. It works out of the box.
Zero setup required
Upload as Text works immediately on any LibreChat instance. It uses built-in text parsing ā you don't need OCR, a RAG pipeline, or any external service to get started.
How to use it
Open the palette
Click + in the message composer. You can also drag the file onto the composer.
Choose a source
In the Attach section, select From Local Computer, or From SharePoint when it is configured. The default uploader does not ask you to choose a model or tool destination.
If your administrator enabled legacyFileUploadUX, choose the destination yourself: select More upload options, then Upload as Text.
Choose your file
Select the file. LibreChat chooses native provider delivery, text extraction, or tool-only storage from the file type and endpoint capabilities.
Ask your question
Type your prompt as usual. Selected File Search and Code tools receive the file only when they need it.
When you select several files, LibreChat skips individual duplicates and files over the per-file size limit, names the skipped files in a notice, and continues uploading the valid files. The file-count and total-batch-size limits still apply to the files that remain; if the surviving batch exceeds either limit, the batch is rejected together. Single-file behavior is unchanged.
Don't see the option?
With legacyFileUploadUX enabled, if Upload as Text doesn't appear under More upload options, the context capability may have been disabled by your admin. It's on by default, but if the capabilities list was customized, context needs to be explicitly included. See the configuration section below.
Paste long text as a file
In the normal message composer, LibreChat can turn a paste longer than 2,500 characters into an Upload as Text attachment. This keeps a large paste out of the input while still providing its contents to the model through the conversation context. The first attachment is named pasted-text.txt; additional pasted-text attachments receive numbered names.
The browser-local Paste long text as a file setting is enabled by default under Settings > Chat > Sending. Shorter pastes and text pasted while answering an Agent's Ask User form remain inline. If context uploads are unavailable, the text also remains inline. If an attachment upload fails, LibreChat restores the text to the composer when it can do so without overwriting a newer draft.
Pasted-text attachments follow the same file-size, token, and fileTokenLimit rules as other Upload as Text files.
What happens under the hood
When an upload is routed to text, LibreChat doesn't dump raw bytes into the prompt. It runs through a processing pipeline to extract clean, readable text:
- MIME type detection ā LibreChat checks what kind of file you uploaded (PDF, image, audio, source code, etc.) by inspecting its MIME type.
- Method selection ā Based on the file type and what services are available, it picks the best extraction method using this priority:
| Priority | Method | When it's used |
|---|---|---|
| 1st | OCR | File is an image or scanned document, and OCR is configured |
| 2nd | STT (Speech-to-Text) | File is audio, and STT is configured |
| 3rd | Text parsing | File matches a known text MIME type |
| 4th | Fallback | None of the above matched ā tries text parsing anyway |
A .pdf on an instance with OCR configured:
ā OCR kicks in. Great for scanned docs and complex layouts.
A .pdf on a default instance (no OCR):
ā Text parsing handles it. Works well for digitally-created PDFs.
A .py Python file:
ā Straight to text parsing. Source code is already text ā no conversion needed.
An .mp3 on an instance with STT configured:
ā Speech-to-Text transcribes it into text for the conversation.
A .png screenshot with no OCR configured:
ā Falls back to text parsing (limited results ā consider setting up OCR for images).
- Token truncation ā The extracted text is trimmed to the
fileTokenLimit(default: 100,000 tokens) so it doesn't blow past the model's context window. - Prompt injection ā The text gets included in the conversation context, right alongside your message.
When you preview or download an Upload as Text attachment, LibreChat serves the extracted text stored with the file record. Downloads use a .txt filename even when OCR or another parser produced the stored text and there is no original backing file to stream.
Which files are supported
These are parsed directly ā they're already text, so no conversion is needed.
- Plain text (
.txt), Markdown (.md), CSV, JSON, XML, HTML, CSS - Programming languages ā Python, JavaScript, TypeScript, Java, C#, PHP, Ruby, Go, Rust, Kotlin, Swift, Scala, Perl, Lua
- Config files ā YAML, TOML, INI
- Shell scripts, SQL files
Text parsing handles these out of the box. If OCR is configured, it takes over for better accuracy on complex layouts.
- PDF ā digital and scanned (scanned PDFs benefit from OCR)
- Word ā
.docx,.doc - PowerPoint ā
.pptx,.potx,.ppt - Excel ā
.xlsx,.xls - EPUB books
Images require OCR to produce useful text. Without it, results will be poor.
- JPEG, PNG, GIF, WebP
- HEIC, HEIF (Apple formats)
- Screenshots, photos of documents, scanned pages
Audio files require STT to be configured. There's no fallback ā audio can't be "text parsed."
- MP3, WAV, OGG, FLAC
- M4A, WebM
- Voice recordings, podcast clips
LibreChat normalizes shell-script MIME variants reported by Chrome on Linux (application/x-shellscript) and libmagic (text/x-shellscript) to the canonical application/x-sh before checking the endpoint allowlist. Custom supportedMimeTypes rules must still permit application/x-sh.
Unified uploads and tool provisioning
By default, one attachment action replaces the old destination chooser. LibreChat decides how the file reaches the model, while tools are provisioned lazily:
Model context
Supported files reach the model through native provider delivery or extracted text, according to MIME type, endpoint capability, and deployment configuration.
Upload for File Search (RAG)
When File Search is selected, LibreChat indexes eligible attachments only when the run needs the tool.
Standard Upload
When Code is selected, LibreChat makes eligible attachments available to the Code environment only when the run needs them.
Operators can restore the earlier destination chooser with fileConfig.legacyFileUploadUX, or control automatic routing with defaultLLMDeliveryPath.
Typical routing:
| Situation | Best option |
|---|---|
| "Read this 5-page contract and summarize it" | Native PDF delivery or extracted text |
| "I have 50 PDFs, find what mentions pricing" | Lazy File Search provisioning |
| "What's in this screenshot?" | Native image delivery |
| "Run this Python script" | Lazy Code provisioning |
| "Review this code file for bugs" | Extracted text |
The context capability
Under the hood, Upload as Text is powered by the context capability. This is what controls whether the feature appears in your chat UI.
The context capability is enabled by default. You only need to touch this if your admin has customized the capabilities list and accidentally left it out.
endpoints:
agents:
capabilities:
- "context" # This is what enables "Upload as Text"The same context capability also powers Agent File Context (uploading files through the Agent Builder to embed text into an agent's system instructions). The difference is where the text ends up:
| Upload as Text | Agent File Context | |
|---|---|---|
| Where | Chat input (any conversation) | Agent Builder panel |
| Scope | Current conversation only | Persists in agent's instructions |
| Use case | One-off document questions | Building specialized agents with baked-in knowledge |
Token limits and truncation
When a file is too long to fit in the model's context window, LibreChat truncates the extracted text to stay within bounds. This happens automatically ā you don't need to worry about it, but it's good to know how it works.
fileConfig:
fileTokenLimit: 100000 # Default: 100,000 tokensTruncation means lost content
If your file exceeds the limit, the text is cut off at the end. If you're getting incomplete answers, this might be why. You can increase fileTokenLimit, but keep in mind that larger values use more tokens per message ā which increases cost and may hit the model's own context limit.
Rules of thumb:
- 100k tokens ā a 300-page book (plenty for most use cases)
- If you're working with very large files, consider File Search (RAG) instead ā it only retrieves the relevant sections rather than stuffing everything into context
Optional: boosting extraction with OCR
Text parsing works fine for digitally-created documents (PDFs saved from Word, code files, plain text). But if you're uploading scanned documents, photos of pages, or images with text, the built-in parser won't get great results.
That's where OCR comes in. When configured, LibreChat automatically uses OCR for file types that benefit from it ā you don't need to do anything differently as a user.
File handling configuration reference
This section is for admins who want to control which file types get processed by which method. The defaults work well ā you only need to touch this if you want to fine-tune behavior.
Troubleshooting
Related
- OCR for Documents ā Set up optical character recognition for images and scans
- RAG API (Chat with Files) ā Semantic search over large document collections
- Agents ā File Context ā Embed file content into an agent's system instructions
- File Config reference ā Full YAML schema for file handling
How is this guide?
RAG API (Chat with Files)
Retrieval-Augmented Generation (RAG) API for document indexing and retrieval using Langchain and FastAPI. This API integrates with LibreChat to provide context-aware responses based on user-uploaded files.
OCR for Documents
Learn how to configure Optical Character Recognition (OCR) to enhance text extraction in LibreChat's file upload features.