How to detect code plagiarism
Detecting code plagiarism takes three things: a structural comparison of the class, a look outside it at the web, past terms and AI, and a careful read of the matches before anyone is accused. This guide walks through each one.
2-day free trial. Checks every file against classmates, the web and AI, in 65+ languages.
palindrome.jscheck.jsThe most common disguise: new names and a new comment (highlighted). To a structural comparison, the two are the same program.
Signs you can spot by hand
Before any tool, experienced graders notice patterns. None of these proves anything alone, but each is a reason to look closer:
- The same mistake. Two submissions with the same bug, the same off-by-one or the same wrong edge case. Honest students rarely share an error.
- Odd details that match. The same unusual variable name, the same dead code, the same leftover debug print, the same strange spacing.
- Code above the course. Features, libraries or idioms the course has not covered, used fluently.
- A change of voice. Parts of one file written in clearly different styles, or work that does not match the student's earlier submissions.
- Comments that explain the obvious, or describe code that is not there. Both are common in copied and AI-written work.
By hand, this works for a handful of submissions. Past that, you need a tool to decide which pairs to read.
Step by step
Step 1Set the rules before the assignment
Say what collaboration is allowed, whether AI tools are, and how sources should be credited. Put it in the assignment itself. Everything after this step is easier to defend when the rule was written down.
Step 2Compare the class by structure
Run every submission against every other with a structural tool. These tokenize the code, so names, comments and formatting drop out, and then compare what is left. Leave out the starter code you handed out, or every submission will match it.
Step 3Look outside the class
Most copied code today comes from outside the class: GitHub, Stack Overflow, tutorial sites, and last year's students. A peer-only comparison cannot see any of it. Check the submissions against web sources and against earlier terms of the course.
Step 4Check for AI-written code
Code from ChatGPT, Claude, Gemini or Copilot is often unique to each student, so it matches nothing. An AI code detector looks at how the code is written instead. Treat its result as a question to ask, not an answer.
Step 5Read the matches, not the scores
Sort by score and open the top pairs. For each one, discount starter code, short programs and textbook algorithms, then look for what is hard to share by accident: the same bug, the same odd structure, the same dead code.
Step 6Talk to the student and write it down
Ask the student to walk you through their code and change a part of it. Someone who wrote it can. Keep the matched lines, the source and your notes together, in case the case goes further.
Steps 2 to 5 in one check
Classmates, past terms, the web and AI, with the matched lines side by side.
2-day free trial
Common disguises
Students who copy usually change something. Here is what the common changes do against a structural comparison:
| Change | Hides the copy? |
|---|---|
| Renaming variables and functions | No, names are ignored |
| Rewriting comments, reformatting | No, both are ignored |
| Reordering independent lines or functions | Rarely, most of the structure survives |
| Adding unused code | Lowers the score, the matched part still shows |
| Translating to another language | Sometimes, depending on the tool |
| Asking an AI to rewrite it | Often, which is why AI detection is its own step |
What MOSS misses shows real refactored copies next to the scores they got.
Tools for each step
| MOSS, JPlag, Dolos | Codequiry | |
|---|---|---|
| Compare the class by structure | Yes | Yes |
| Leave out starter code | Yes | Yes |
| Check the web | No | Yes |
| Check past terms | Only if you add them by hand | Yes |
| Detect AI-written code | No | Yes |
| Cost | Free | Plans, free trial |
The free tools compared in detail: MOSS vs Dolos vs JPlag. For what a full check looks like, see the code plagiarism checker, and for the concepts behind all of this, what code plagiarism is.
Frequently asked questions
How do teachers detect code plagiarism?
They compare every submission in the class by structure with a tool like MOSS, JPlag or Codequiry, check the work against the web, past terms and AI, and then read the flagged pairs line by line before talking to the student.
Can you detect plagiarism if the variable names are changed?
Yes. Structural comparison ignores names, comments and whitespace, so a renamed copy matches almost as strongly as an exact one.
Can plagiarism be detected across programming languages?
Often, yes. A solution translated from Python to Java keeps the same structure, and tools that compare structure rather than text can match it.
How do you prove a student copied code?
You do not prove it with a score. You show the matched lines, the source, and anything hard to share by accident, such as the same bug or dead code, and you ask the student to explain their work. Their explanation usually settles it.
What similarity percentage is too high?
There is no fixed cut-off. Short programs and starter code can score high between honest students, and a disguised copy can score lower. Use the score to decide what to read, not what to conclude.
Can you detect code written by ChatGPT?
An AI code detector can flag code that is likely AI-written and say why. It is a signal to follow up on, especially when a submission does not match the student's earlier work, not proof on its own.
Is there a free way to detect code plagiarism?
Yes. MOSS is free for academic use, JPlag and Dolos are open source, and Codequiry's free check compares up to 20 submissions with each other with no account. None of these search the web or detect AI.
Run the check on a real assignment
Upload a class's submissions and see which match classmates, past terms, the web or AI.
Start free trial2-day free trial
Just one assignment? Run a single check