How ChatGPT Scanned 170K Lines of Code in Seconds
In this article
Yes, ChatGPT can scan large codebases quickly—170,000 lines in seconds is realistic when you feed it the code in a structured way and ask targeted questions. The trick isn’t raw upload speed; it’s about breaking the code into manageable chunks and using the right prompts. This guide walks you through the exact steps I used to save hours of manual review, plus common pitfalls and fixes.
What You'll Need
- A ChatGPT account (free tier works, but Plus/Pro with longer context is better for very large files)
- Your codebase accessible as plain text files (e.g., .py, .js, .ts, .java)
- A way to split files if they’re huge—like a terminal or a text editor
- Optional: a tool to copy file contents, like `cat` on Linux/macOS or `Get-Content` on Windows
Step-by-Step
- Prepare your code for scanning. If your code is in a single file under ~50,000 lines, you can copy it directly. For larger codebases, split into logical modules (e.g., by folder or by file). Use your terminal to create a combined text file: on macOS/Linux run
cat src/*.py > combined.txt; on Windows PowerShell runGet-Content src\*.py | Out-File combined.txt. This keeps the code in one place for easier copying. - Open ChatGPT and start a new conversation. This isolates the context so previous chats don’t interfere. If you have a long context model (like GPT-4 Turbo or GPT-4o), it handles more code per message.
- Paste the code in chunks. ChatGPT has a message length limit (roughly 25,000–32,000 tokens for most models, which is about 20,000–30,000 lines of simple code). For 170K lines, you’ll need multiple messages. Start with the first chunk—say, 30,000 lines—and paste it directly into the chat. If it’s too long, split into smaller pieces (10,000–15,000 lines each).
- Give a clear instruction before each chunk. After pasting the first chunk, type something like: “I’m going to send you my codebase in parts. For each part, identify any bugs, security issues, and performance bottlenecks. Do not summarize; just list findings with line numbers.” This sets the expectation.
- Send the next chunks. After ChatGPT processes the first chunk, paste the next one. Keep the same instruction if you want consistency, or ask follow-up questions like “Any SQL injection risks in this part?”
- Ask for a consolidated report. Once all chunks are sent, prompt: “Now combine all your findings into a single report grouped by severity (critical, high, medium, low). Include the file and line numbers.” This gives you the big picture without re-reading everything.
- Use targeted queries for specific tasks.
Common Mistakes
- Pasting the entire 170K lines in one go. It will hit the token limit and get truncated, losing context. Always split.
- Not giving a specific task. “Review this code” is vague; you’ll get generic advice. Instead, say “Find null pointer exceptions” or “Check for race conditions.”
- Ignoring line numbers. ChatGPT often references line numbers relative to the chunk, not the whole file. Keep track of your chunk boundaries so you can map them to the real file.
- Sending code without context. If you’re scanning a specific function, include the surrounding classes or imports. Otherwise, ChatGPT may misinterpret variable types.
Tips
- Use a code-splitting script. Write a simple Python script to split your code into 500-line files with a header comment showing the original file and line range. This makes it easy to paste and track.
- Leverage ChatGPT’s memory in a single conversation. Keep all chunks in the same chat so it remembers earlier parts. Starting a new chat loses that context.
- Ask for a summary first. If you’re unsure what to look for, ask “Give me a high-level overview of what this code does” before diving into specifics.
- Use the “analyze” feature if available. Some ChatGPT interfaces allow file uploads. Uploading a .txt file with the code can bypass copy-paste limits, but be aware of file size limits (usually around 25MB).
Troubleshooting
- “The message is too long.” This means you exceeded the token limit. Split your chunk into smaller pieces—try 10,000 lines or less. If you’re using a free account, the limit is lower, so consider upgrading or using a more concise code format (e.g., remove comments).
- ChatGPT stops mid-scan. This can happen if the conversation gets too long. Start a new chat and re-send the chunks, but this time, ask for a running summary after each chunk so you don’t lose earlier findings.
- Results are generic or off-target. Refine your prompt. For example, instead of “find bugs,” say “look for off-by-one errors in loops” or “check for missing null checks before dereferencing.”
- Line numbers don’t match your files. Because chunks are relative, always note the starting line of each chunk. For example, if chunk 2 starts at line 50,001, add that offset to any line numbers ChatGPT gives.
Frequently Asked Questions
Can ChatGPT really scan 170K lines in seconds?
Yes, but the “scanning” is not instant—it processes each chunk in a few seconds. The total time depends on how many chunks you send. The saving is in the analysis, which would take a human hours or days.
What if my code is proprietary? Is it safe to paste?
ChatGPT uses your input to improve its models, so avoid pasting sensitive or proprietary code if you’re concerned. Use a private instance (like ChatGPT Enterprise) or anonymize variable names and remove secrets before pasting.
Does the free version work?
Yes, but the token limit is smaller, so you’ll need to split into smaller chunks. The paid versions (Plus/Pro) have longer context and can handle more per message.
Can I upload a file directly instead of pasting?
In ChatGPT’s web interface, you can attach a .txt or .js file, but the size is limited (usually around 25MB). For 170K lines, that’s often too big, so pasting in chunks is more reliable.
How do I get line numbers in the output?
Ask ChatGPT to include line numbers in its findings. It will reference the line numbers as they appear in the chunk you pasted, so keep track of your chunk offsets.
What if ChatGPT misses something?
It’s not perfect. Use it as a first pass, then run static analysis tools like ESLint, Pylint, or SonarQube for more thorough checks. Combine both for best results.