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:
- Exceed most models' context windows entirely
- Cost $5–$15 in API fees for a single read operation
- Leave no room for your actual question or other context
- 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 Agent Mode draining credits — why Agent Mode uses so many requests
- Cursor usage limit mid-session — what to do when you hit the request cap
- Cursor tools hub — all Cursor guides and how-tos