LibreChat

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:

  1. MIME type detection — LibreChat checks what kind of file you uploaded (PDF, image, audio, source code, etc.) by inspecting its MIME type.
  2. Method selection — Based on the file type and what services are available, it picks the best extraction method using this priority:
PriorityMethodWhen it's used
1stOCRFile is an image or scanned document, and OCR is configured
2ndSTT (Speech-to-Text)File is audio, and STT is configured
3rdText parsingFile matches a known text MIME type
4thFallbackNone of the above matched — tries text parsing anyway
  1. 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.
  2. 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:

Quick decision guide:

SituationBest 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.

librechat.yaml
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 TextAgent File Context
WhereChat input (any conversation)Agent Builder panel
ScopeCurrent conversation onlyPersists in agent's instructions
Use caseOne-off document questionsBuilding 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.

librechat.yaml
fileConfig:
  fileTokenLimit: 100000  # Default: 100,000 tokens

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


How is this guide?