How plagiarism checkers work
Plagiarism checkers can compare a submission with millions of documents in seconds and still point to the exact lines that match. The techniques that make this possible are well understood, and knowing them tells you what a checker can see through, what it cannot, and how to read its results. This guide walks through the pipeline for both written work and source code.
Checks every file against classmates, the web and AI, in 65+ languages.
The basic pipeline
Comparing every sentence of a submission with every sentence of every other document would be impossibly slow. Every practical checker instead follows the same broad steps:
- Normalise the document, removing what a copier can change freely.
- Break it into small overlapping pieces of a fixed length.
- Fingerprint each piece as a short number, and keep a representative sample.
- Look up which other documents share those fingerprints, using an index.
- Align the shared fingerprints back into continuous matched passages.
- Score and present the matches, side by side, with their sources.
Text checkers and code checkers differ mostly in the first step, and that difference decides what each can detect.
Normalising and tokenising
Normalisation decides what counts as "the same". For prose, a checker typically lowercases text, strips punctuation and extra spaces, and may reduce words to their stems so that "copied" and "copying" match. Some remove very common words.
For source code, normalisation goes much further, because code can be changed mechanically without changing what it does. A code checker parses the program and turns it into a sequence of tokens that keeps the structure and discards the surface:
| Original line | Token sequence |
|---|---|
total = total + price * qty | ID = ID + ID * ID |
s = s + p * n # running sum | ID = ID + ID * ID |
Names become a generic identifier, comments and whitespace disappear, and literals may be generalised. Two lines that look different to a person, and are entirely different to a text checker, become identical. This single step is why renaming and reformatting, the two most common disguises in programming courses, do not work against a code checker.
Fingerprints and winnowing
The normalised document is cut into overlapping pieces of k tokens or characters, called k-grams. A document of 1,000 tokens with k = 5 has 996 of them. Each k-gram is hashed to a short number, its fingerprint. Two documents that share a passage share the fingerprints of the k-grams inside it.
Keeping every fingerprint for every document is expensive, so checkers keep a sample. Sampling at random would risk missing matches. Winnowing, described by Schleimer, Wilkerson and Aiken in 2003, solves this: slide a window across the fingerprints and keep the smallest one in each window. Because both documents select by the same rule, a shared passage at least as long as the window is guaranteed to produce at least one shared selected fingerprint. Short coincidences below a noise threshold are ignored by design.
The choice of k matters. Too small and common phrases or idioms match everywhere; too large and a copier who changes every few tokens breaks every fingerprint. Checkers tune it for the content: shorter for code tokens, where idioms are short, longer for prose.
Winnowing underlies MOSS, the long-standing academic code similarity service. Its strengths and the copying it misses are discussed in what MOSS misses.
Aligning fingerprints into matches
Shared fingerprints are evidence, but a reviewer needs passages. The checker maps shared fingerprints back to positions in both documents and joins neighbouring ones into continuous matched regions, tolerating small gaps where a few tokens were inserted or changed.
An alternative to fingerprinting for pairwise comparison is greedy string tiling, used by JPlag: repeatedly find the longest common run of tokens between two documents, mark it as a tile, and continue with what is left. It handles reordered blocks well, since each block can be tiled wherever it appears.
The similarity percentage is then computed from the matched regions, usually as the share of one document covered by matches. Because it is measured from each side, a short file copied whole into a long one scores high from the short side and low from the long side. Our page on code similarity scores explains how to read the number.
Structural comparison for code
Tokens defeat renaming and reformatting. A determined copier may go further: reorder independent statements, swap a for loop for a while loop, split a function in two, or add statements that do nothing. Methods that compare deeper structure aim to see through these.
- Abstract syntax trees. The program is parsed into a tree of its constructs. Comparing subtrees finds matching structure even when the order of independent parts changes.
- Control and data flow. Representing which statements depend on which captures what the program does rather than how it is laid out, and resists inserted dead code.
- Learned representations. Machine learning models trained on code map functionally similar fragments to nearby points, catching rewrites a rule would miss. They need careful calibration so that every program solving the same small task does not look alike.
Each step deeper catches more disguise and costs more to compute, and the risk of matching honest solutions to a constrained task rises too. Good code checkers combine methods and exclude starter code so that the shared part of an assignment does not swamp the result. How Codequiry's engines compare on the same test set is published in the engine benchmarks; the approach behind the Zeus engine is described in Zeus. For a survey of methods, see code similarity detection methods compared.
See structural matching on your own code
Upload a class. Renamed and reformatted copies are matched and shown side by side.
Searching the web and code repositories
Comparing a class with itself uses the steps above directly. Comparing it with the web adds a retrieval problem: find the handful of pages worth comparing among billions. Checkers do this in two ways.
- Query a search engine with distinctive passages from the submission and fetch the top results for full comparison.
- Maintain their own index of crawled pages, repositories and Q&A answers, fingerprinted in advance, and look submissions up in it directly.
For code, the sources that matter most are public repositories, gists and Q&A answers. Codequiry searches the web, GitHub and Stack Overflow and links each match to where it was found. See GitHub plagiarism checking.
What no matching method can see
- Sources that are not indexed: private repositories, paid solution sites, messages between students.
- Work written for someone else: a contract-written assignment is new text with no source.
- AI-generated work: also new text with no source. Detecting it needs a method that looks at how the work is written; see how AI detectors work.
- Whether similarity was allowed: cited, permitted or coincidental overlap looks the same to an algorithm as copying.
That last point is why every result needs a person to read it. The algorithm finds the shared material; deciding whether it is plagiarism is a judgement about context. The practical side of that judgement is in how to detect code plagiarism.
Frequently asked questions
How do plagiarism checkers detect copying?
They break each document into small overlapping pieces, turn the pieces into compact fingerprints, and look for fingerprints shared with other documents. Long runs of shared fingerprints become a match. Code checkers first convert programs into tokens or syntax trees so that renaming and reformatting do not hide the copy.
What is winnowing in plagiarism detection?
Winnowing is a way of choosing a small, representative sample of a document's fingerprints so that comparison is fast, while guaranteeing that any shared passage above a set length will still be detected. It was described by Schleimer, Wilkerson and Aiken in 2003 and underlies MOSS.
Can plagiarism checkers detect paraphrasing?
Partly. Fingerprint matching finds passages that share wording. Light paraphrase leaves enough shared fragments to be found; thorough paraphrase may not. For code, structural comparison sees through renaming and reformatting, which are the code equivalent of paraphrase.
How do plagiarism checkers search the internet?
They either query search engines with distinctive passages from the submission, or compare against their own index of crawled pages and repositories. Either way, only public material can be found: private repositories and pages behind logins are out of reach.
Why does changing variable names not fool a code plagiarism checker?
Because code checkers compare structure, not names. Before comparison every identifier is replaced with a generic token, so total = total + price and s = s + p become the same sequence.
Can plagiarism checkers detect AI-written work?
Not by matching, because generated work has no source. Detecting it needs a different method that judges how the work is written. Codequiry runs both in one check for code.
Structural matching, web search and AI detection
One check compares code by structure, searches the web, GitHub and Stack Overflow, and flags AI-written code.
Start a check Pay as you go with credits. Comparing files is free.