AI code detectors, including the one on this page, give you a score or a verdict. It is fair to ask how much that is worth. The honest answer from published research is: less than many people assume, and it depends a lot on the tool, the code and how it was produced. This page summarises what peer-reviewed and preprint studies on detecting AI-generated source code actually report. We read the papers linked below in October 2026. Results come from specific datasets and specific versions of tools, so read them as evidence about the problem, not as ratings of any product you might use today.
The short version
- General-purpose AI text detectors performed poorly on code in the studies we read, often close to a coin flip.
- Errors go both ways. Some tools miss nearly all AI code; others flag a large share of human code.
- Detectors built specifically for code do better in research settings, but results drop when the code comes from a different model, language or dataset than the one they were tuned on.
- Short and standard code is the hardest case.
What the studies found
Pan et al., ICSE-SEET 2024. In Assessing AI Detectors in Identifying AI-Generated Code, researchers collected 5,069 programming problems with human-written Python solutions and had ChatGPT generate solutions using 13 different prompt variants. They tested five AI-content detectors: GPTZero, Sapling, GPT-2 Detector, DetectGPT and GLTR. Their conclusion was that the existing detectors performed poorly at telling human-written from AI-generated code. In their results table, GPTZero's accuracy at the baseline prompt was about 50%, because it labelled almost everything as human: it correctly identified 99% of the human code but only about 0.2% of the AI code. DetectGPT made the opposite mistake. It correctly identified only about 28% of the human code, which means roughly 72% of the human-written solutions were labelled as AI.
Suh et al., ICSE 2025. An Empirical Study on Automatically Detecting AI-Generated Source Code: How Far Are We? tested the same kinds of text detectors plus GPTSniffer, a detector fine-tuned on source code, on Python, Java and C++ from several benchmarks, with AI code from ChatGPT, Gemini Pro, GPT-4 and StarCoder2-Instruct. Average accuracy for the text detectors was between about 48% and 51%. GPTSniffer averaged about 57%, but it varied enormously: the authors note it reached only about 32% accuracy on ChatGPT-generated Java from HumanEval, even though it had been fine-tuned on ChatGPT-generated Java. They concluded that existing tools lack sufficient generalizability to be practically deployed. Their own best model, built from code features, reached an F1 score of 82.55 on their data, which is better, but still a research result rather than a deployed tool.
Yang et al., 2023 preprint. Zero-Shot Detection of Machine-Generated Codes reports that existing training-based and zero-shot text detectors were ineffective at detecting code, and attributes this to the different statistical properties of code compared with natural language. The authors propose a modified method that performed better on their Python benchmarks.
Xu et al., ACM TOSEM. One Size Does Not Fit All studied perplexity, a common signal that measures how predictable text is to a language model. They found it had the best generalization of the methods they compared but limited accuracy and speed, and that it was unsuitable for high-level programming languages.
Why false positives happen
A false positive here means human-written code labelled as AI. The studies above show it is not a rare edge case for some tools. One likely reason, though the papers do not prove it for every tool, is that many detection signals are about predictability: AI output tends to be the kind of code a language model finds likely. But a lot of good human code is also predictable. Programming courses teach conventions, style guides and standard patterns, and well-taught students follow them. Clean, conventional code can therefore look "AI-like" to a statistical tool without any AI being involved.
Tools also differ in which way they lean. As Pan et al.'s results show, a detector can look reasonable on overall accuracy while being badly wrong for one group. That is why a single accuracy number, without the rates for human and AI code separately, tells you very little.
Why short and standard code is especially hard
Detectors need evidence, and a short snippet does not contain much. In Ye et al.'s zero-shot code detection study, the authors grouped code by length and reported that, in general, all the detectors they tested performed better as code length increased within the 0 to 1,000 character range. Many student exercises are shorter than that.
Standard tasks add a second problem. There are only so many sensible ways to reverse a list, check a palindrome or implement binary search. A human's correct answer and a model's correct answer can be nearly the same code, and no tool can reliably separate them on the code alone.
What about tools schools already use?
Some widely used tools say directly that code is out of scope. Turnitin's AI writing detection FAQ says its model removes text that appears to be code and does not reliably detect AI-generated code; see does Turnitin detect AI code. Similarity tools such as MOSS and JPlag compare submissions with each other rather than judging authorship. We did not find independent, published accuracy figures for most commercial AI code detectors, so if a vendor quotes one, ask what data it was measured on.
How to use a detector sensibly
- Read the reasons, not just the score. A useful tool explains what it noticed so a person can check it.
- Weigh length and task. A flag on a short, standard function deserves much less weight than one on a long, unusual program.
- Look at other evidence. Commit history, drafts and a short conversation about the code are far more informative. Our guide for teachers using AI code detection covers this.
- Never treat a score as proof. The research does not support it.
What this means for the detector on this page
Our detector looks for style patterns associated with AI-written code and shows the reasons behind its result. It is subject to the same limits described above, and we do not publish a headline accuracy figure for it. Use it to see how your code reads and what a grader might ask about, not as a verdict. If a tool has flagged work you wrote yourself, see my code was flagged as AI.
Frequently asked questions
Is there a single accuracy number for AI code detectors?
No. Studies test different tools, models, languages and datasets, and results vary widely between them. A detector that does well on one benchmark can fall to around chance on another. Be wary of any single headline accuracy figure that does not say what it was measured on.
Can an AI code detector flag code I wrote myself?
Yes. In a 2024 ICSE study, one of the detectors tested labelled about 72% of the human-written Python solutions as AI-generated, by our calculation from the paper's reported rates. Other tools made the opposite mistake and called nearly everything human. Both kinds of error are documented.
Why is short code so hard to judge?
There is less to go on. Detectors look for statistical or stylistic patterns, and a ten-line function gives them very few. One study that grouped code by length found that detectors generally did better as code got longer, within the range it tested. Standard solutions to common exercises also look alike whoever writes them.
Are newer, code-specific detectors better?
Research prototypes designed for code have reported better results than general text detectors on their own test sets. One ICSE 2025 paper's best model reached an F1 score of 82.55. That is a lab result on specific datasets, not a guarantee for any product, and it still means a meaningful share of mistakes.
Should a detector score decide an academic integrity case?
The research we read does not support using a score alone. Even the better results leave room for errors, and Turnitin, for example, says its AI writing model does not reliably detect AI-generated code. A score is a reason to look closer and talk to the student, not a finding.
Try the detector
Have a snippet you are unsure about? Paste it into the free AI Code Detector to get a verdict, an AI probability and the reasons behind it. No sign-up, and your code is not stored.