New Breakthrough Catch AI-written code before you grade it. Our most accurate model yet. It finds 90% of AI and GPT code with only 1.3% false flags. 90% caught, 1.3% false flags. Start checking Start checking
New: MCP integration. Run plagiarism scans from Claude, Cursor or any AI assistant. Run scans from Claude or Cursor. Set it up

Code similarity detection methods, compared

Every code plagiarism checker answers the same question, do these programs share more than chance allows?, in one of a handful of ways. Here is how each method works, what it catches, what it misses, and why good tools combine several.

2-day free trial. Checks every file against classmates, the web and AI, in 65+ languages.

What a token-based checker actually compares Names and comments are gone. The shape of the program is left.
Example
Sourcecount.py
1# count words longer than n2def count_long(words, n):3 total = 04 for w in words:5 if len(w) > n:6 total += 17 return total
Tokenscompared
12DEF ID ( ID , ID ) :3 ID = NUM4 FOR ID IN ID :5 IF ID ( ID ) > ID :6 ID += NUM7 RETURN ID
Names: droppedComments: droppedStructure: kept

Rename every variable and this token stream does not change. That is why renaming never hides a copy from a structural checker, and why rewriting the statements themselves sometimes does.

Text comparison

The simplest method compares files line by line, like diff, or looks for shared phrases, like an essay checker such as Turnitin. It is fast and easy to explain.

It is also the easiest to defeat. Renaming variables, reformatting or rewriting comments changes nearly every line of text and none of the program. Text comparison is useful for spotting identical files, and little else.

Token fingerprints (MOSS)

Token-based methods first reduce each program to a stream of tokens, as in the example above: keywords and punctuation stay, names and comments go. Then they compare the streams.

MOSS does it with winnowing: it hashes every short run of tokens, keeps a representative sample of those hashes as the file's fingerprints, and reports pairs that share many of them.

  • Catches: renaming, reformatting, new comments, moved functions.
  • Misses: statements rewritten into equivalent forms, which change the token runs. What MOSS misses shows one.

Greedy string tiling (JPlag)

JPlag also works on tokens, but instead of sampling fingerprints it searches for the longest runs the two programs share and tiles both programs with them, longest first. The score is how much of each program the shared tiles cover.

  • Catches: the same edits as fingerprints, with precise match boundaries.
  • Misses: the same thing: rewrites that break up long token runs.

Syntax trees and graphs

Instead of a flat stream, these methods parse each program into a syntax tree, or into a graph of which statements depend on which. Dolos, for example, parses code with tree-sitter before fingerprinting it.

  • Catches: more restructuring. Reordering independent statements or swapping loop forms changes the text and tokens but leaves much of the tree or dependency graph intact.
  • Costs: more computation per pair, and a parser for every language.

Learned models

Newer approaches train a model to turn each program into a numeric representation, so programs that do the same thing land close together even when their text and tokens differ. This is what makes some cross-language matches possible: a Python solution and its Java translation can look alike to a model when they look nothing alike as tokens.

Codequiry's Zeus engine is built on this idea. Like any model, it gives a score to review, not a verdict.

Beyond the class

Every method above compares the programs you give it with each other. Two more checks cover what that cannot see:

  • Web search. Each program is compared with public code on GitHub, Stack Overflow, Software Heritage and the indexed web, and with earlier terms. This finds a copy even when no classmate made the same one.
  • AI-authorship detection. A classifier looks at how the code is written rather than what it matches, because AI output is usually different for every student. How AI code detection works.

All of these in one check

Structure, web sources and AI, with the matched lines side by side.

Start free trial

2-day free trial

Side by side

MethodIgnores renamingSurvives restructuringSees outside the batch
Text comparisonNoNoNo
Token fingerprintsYesPartlyNo
Greedy string tilingYesPartlyNo
Syntax trees and graphsYesBetterNo
Learned modelsYesBetter, across languagesNo
Web searchDepends on the matcherDepends on the matcherYes
AI detectionAnswers a different question: who wrote it, not what it matches

In practice, the method matters less than the combination. For how the tools compare, see MOSS vs Dolos vs JPlag, and for putting it to use, how to detect code plagiarism.

Frequently asked questions

How does code similarity detection work?

Most tools turn each program into a sequence of tokens or a syntax tree, which drops names, comments and formatting, and then look for long shared stretches between programs. The score reflects how much of each program is shared.

What algorithm does MOSS use?

Winnowing. MOSS hashes short runs of tokens into fingerprints, keeps a representative subset of them, and reports the pairs of files that share the most.

What algorithm does JPlag use?

Greedy string tiling over token sequences. It looks for the longest shared runs of tokens first and covers as much of both programs as it can with them.

Why does text comparison fail for code?

Because the text is the part students change first. Renaming variables or reformatting a file changes almost every line of text while leaving the program exactly the same.

Can similarity detection find AI-written code?

Not on its own. AI-written code is usually different for every student, so it matches nothing. Detecting it takes a separate classifier that looks at how the code is written.

Which method is the most accurate?

None wins everywhere. Token methods are fast and hard to fool with renaming; tree and graph methods survive more restructuring but cost more; web search and AI detection cover what comparison inside a class cannot see. Good tools combine them.

See the methods work on real code

Upload a batch and check it against each other, the web and AI.

Start free trial

2-day free trial

Just one assignment? Run a single check

Tools and sources referenced on this page

Codequiry is compared with these tools above. Each link goes to the project's official site so you can check the claims yourself.

  • MOSS (Measure of Software Similarity) Stanford University, Alex Aiken

    Free academic similarity service from 1994 that fingerprints code with winnowing and reports matching passages between submissions.

  • Winnowing: Local Algorithms for Document Fingerprinting Schleimer, Wilkerson and Aiken, SIGMOD 2003

    The paper that defines the fingerprinting algorithm MOSS is built on, and the reference point for every "winnowing-based" detector.

  • JPlag Karlsruhe Institute of Technology, open source

    Open-source token-based detector that compares programs with Greedy String Tiling and produces a similarity report per pair.

  • Dolos Ghent University, open source

    Open-source similarity tool built on tree-sitter parsing, with a web interface for exploring clusters of related submissions.

  • Turnitin Turnitin, LLC

    Commercial text plagiarism and AI-writing detection for essays and documents. It is not designed for source code.