Upload Files as Text
Drop any file into your chat and let LibreChat read it — no setup needed.
Upload Files as Text
Ever wanted to hand a PDF, a code file, or a spreadsheet to the AI and just say "read this"? That's exactly what Upload as Text does.
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
Click the attachment icon
In the chat input bar, click the paperclip (📎) icon.
Pick "Upload as Text"
From the dropdown menu, select Upload as Text. This tells LibreChat to read the file contents rather than pass it as a raw attachment.
Choose your file
Select the file from your device. LibreChat will extract the text and embed it directly into your message.
Ask your question
Type your prompt as usual. The AI now has the full text of your file in context and can reference any part of it.
Don't see the option?
If "Upload as Text" doesn't appear, 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.
What happens under the hood
When you upload a file this way, LibreChat doesn't just 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 |
- 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.
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
Upload as Text vs. other upload options
LibreChat has three ways to upload files. Each one works differently and suits different situations:
Upload as Text
Extracts the full file content and drops it into the conversation. Best for smaller files where you want the AI to read everything — contracts, code files, articles. Works with all models, no extra services needed.
Upload for File Search (RAG)
Indexes the file in a vector database and retrieves only the relevant chunks when you ask a question. Better for large files or collections of files where dumping everything into context would waste tokens. Requires the RAG API.
Standard Upload
Passes the file directly to the model — used for vision models analyzing images, or code interpreter running scripts. No text extraction happens.
Quick decision guide:
| Situation | Best option |
|---|---|
| "Read this 5-page contract and summarize it" | Upload as Text |
| "I have 50 PDFs, find what mentions pricing" | File Search (RAG) |
| "What's in this screenshot?" (vision model) | Standard Upload |
| "Run this Python script" (code interpreter) | Standard Upload |
| "Review this code file for bugs" | Upload as Text |
| "Search through our company docs" | File Search (RAG) |
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.
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.
Truncation 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?