Cursor Read File 2MB Limit: Why Large Files Fail and How to Work Around It

Quick Answer

Cursor limits the read_file tool to 2MB per file. Files larger than 2MB cannot be read by Cursor's AI agent, causing errors during code analysis and refactoring tasks. This affects large JSON files, bundled assets, database dumps, and generated code. Workarounds: split large files into smaller modules, use .cursorignore to exclude non-essential large files, or reference specific line ranges instead of entire files.

Understanding the 2MB Limit

Cursor's AI features work by sending file contents to a language model (Claude Sonnet 4 or GPT-4o) for analysis. Each file read consumes tokens from the model's context window:

  • 1KB file ≈ 250 tokens
  • 100KB file ≈ 25,000 tokens
  • 1MB file ≈ 250,000 tokens
  • 2MB file ≈ 500,000 tokens

At 2MB, a single file would consume most or all of the model's available context window, leaving no room for your question, other files, or the model's response. The 2MB limit prevents this scenario.

Common Scenarios Where This Hits

Large JSON fixtures or mock data

Test fixtures, API response mocks, and seed data files frequently exceed 2MB. When you ask Cursor to help write tests that reference these files, it cannot read them.

Bundled or minified assets

Build outputs like bundle.min.js or styles.min.css are often multi-megabyte. Cursor cannot analyze these — use source files instead.

Auto-generated code

Protobuf outputs, GraphQL generated types, and ORM schema files can grow beyond 2MB in large projects. These are typically generated from smaller source definitions.

Legacy monolithic files

Older codebases sometimes have single files with thousands of lines that have grown over years. These may approach or exceed 2MB.

Step-by-Step Workarounds

Workaround 1: Reference Specific Line Ranges

Instead of letting Cursor read the entire file:

@src/data/large-fixture.json:1-50
What is the structure of this JSON file?

This reads only lines 1–50, staying well under the limit while giving Cursor enough context to understand the structure.

Workaround 2: Split Large Files

For source code files approaching 2MB, split them into logical modules:

# Before: one 3MB file
src/api/handlers.ts (3MB, 8000 lines)

# After: multiple focused files
src/api/handlers/auth.ts (200KB)
src/api/handlers/users.ts (150KB)
src/api/handlers/billing.ts (180KB)

This improves both AI accessibility and code maintainability.

Workaround 3: Use .cursorignore

Create or edit .cursorignore in your project root:

# Large generated files
src/generated/**
dist/**
*.min.js
*.min.css

# Large data files
fixtures/**/*.json
seeds/**/*.sql

This prevents Agent mode from attempting to read these files during autonomous operations.

Workaround 4: Extract Relevant Sections

For one-off analysis of large files, extract the relevant portion:

# Extract lines 500-600 from a large file into a temp file
sed -n '500,600p' large-file.json > /tmp/section-to-analyze.json

Then reference the smaller extracted file in your Cursor prompt.

Why This Happens: Context Window Economics

AI models have a fixed context window (typically 128K–200K tokens for current models). Every token of input costs money and processing time. A 2MB file at ~500K tokens would:

  1. Exceed most models' context windows entirely
  2. Cost $5–$15 in API fees for a single read operation
  3. Leave no room for your actual question or other context
  4. Produce slower responses due to the massive input size

The 2MB limit is a practical tradeoff between file access and usability. Most meaningful code analysis can be done on files under 2MB — files above this size are typically data, generated output, or candidates for refactoring.

Common Mistakes to Avoid

  • Trying to force-read large files by splitting prompts: Cursor enforces the limit per-read, not per-session — you cannot read a 4MB file in two 2MB chunks through the AI
  • Ignoring the error and re-prompting: If Cursor fails to read a file due to size, rephrasing your question will not help — the file is still too large
  • Not using .cursorignore in large projects: Without it, Agent mode wastes requests attempting to read large files it cannot process
  • Keeping generated code in the same directory as source: Separate generated files into clearly marked directories and ignore them

When the Limit Actually Matters

For most development workflows, the 2MB limit is invisible. Standard source code files are typically 10–200KB. You will only encounter this limit when:

  • Working with data-heavy projects (ML datasets, large fixtures)
  • Analyzing build outputs or bundles
  • Dealing with auto-generated code from schemas
  • Working in legacy codebases with monolithic files

If you hit this limit frequently, it is often a signal that your project structure could benefit from refactoring — smaller, focused files are better for both AI tools and human developers.

Related Guides

Cursor · Usage Limits & Restrictions

More Cursor usage limits & restrictions guides

Browse all guides in this category to troubleshoot related issues faster.

Browse all guides →

Frequently Asked Questions

Cursor enforces a 2MB limit on the read_file tool to prevent excessive token consumption and context overflow. When a file exceeds 2MB, the AI agent cannot read its contents and will either skip it or report an error. This limit exists because sending a 2MB file to the AI model would consume approximately 500,000 tokens — far more than the model's context window can handle efficiently. The limit applies to all file types regardless of content.

Related Guides

Continue with nearby guides in the same topic to rule out adjacent causes faster.

Cursor Agent Mode Draining Credits Too Fast: Why and How to Fix It

Cursor Agent Mode drains credits fast because each background tool call (file reads, terminal commands, web searches) counts as a separate request against your monthly limit. A single agent task can consume 50–200 requests in minutes. The 2,000-request spike some users saw was a confirmed UI bug — actual usage was lower. Fix: monitor the request counter in Settings → Usage, break large tasks into smaller prompts, and use Ask mode instead of Agent mode for simple questions.

Cursor 'You've Hit Your Usage Limit' Mid-Session: How to Fix

Cursor shows 'You've hit your usage limit' when you exhaust your 500 monthly fast requests on Pro, or when a rate limiter triggers during intensive Agent Mode sessions. This can happen mid-task, stopping the agent before it finishes. Fix: wait 60 seconds and retry (rate limit), upgrade your plan, or switch to slow requests which have no monthly cap but longer response times.

Cursor Not Working: Fixes for the Most Common Errors

When Cursor stops working, the most common causes are a failed AI model connection, an expired API key or subscription, a corrupted extension state, or a VS Code compatibility issue. Start by checking your Cursor account status at cursor.com, then reload the window with Ctrl+Shift+P → Reload Window. Most Cursor issues are resolved by signing out and back in or reinstalling the app.

Claude Code Usage Limit Draining Too Fast: Causes and Fixes

Claude Code drains your usage limit fast because each tool call (read file, write file, run command) counts as a separate token-consuming interaction, and a known prompt caching bug in versions before v2.1.34 inflated costs by 10–20x. Fix: update Claude Code to the latest version, switch the default model from Opus 4 to Sonnet 4, and break large agent sessions into smaller tasks.