Does MOSS Detect AI-Generated Code?

How MOSS, JPlag and Gradescope Code Similarity work, why they compare programs rather than spot AI, and what that means when you check your own programming assignment.

0 / 8,000 characters

MOSS is one of the best-known tools in programming courses, so it is a natural thing to wonder about when AI assistants are everywhere. The short answer is that MOSS does not detect AI-generated code as such. It detects similarity between programs. That difference matters, both for what your instructor can see and for what you should check in your own work. The descriptions of MOSS, JPlag and Gradescope below come from their official pages, which we read in October 2026.

What MOSS actually does

According to the official MOSS page at Stanford, MOSS (Measure Of Software Similarity) is an automatic system for determining the similarity of programs, used mainly to look for plagiarism in programming classes since 1994. An instructor submits a batch of files, and MOSS returns pairs of programs that share code, with the matching passages highlighted side by side. It supports many languages, including C, C++, Java, C#, Python and JavaScript, and it can be told to ignore code that everyone is expected to share, such as starter files from the instructor.

The page is also clear about the limits. It says MOSS is not a system for completely automatically detecting plagiarism, that its scores are not proof of plagiarism, and that someone still has to look at the code.

JPlag and Gradescope work the same way

  • JPlag. The JPlag README describes an open-source tool that finds pairwise similarities among a set of programs and is built to detect plagiarism and collusion even when code has been obfuscated. It supports Java, C++, C#, Python, Kotlin and several other languages. The README does not mention AI detection.
  • Gradescope Code Similarity. Gradescope's guide says the report helps determine how similar students' code is to each other within a single assignment, and that it does not automatically detect plagiarism. It is available for courses with an institutional license.

All three answer the same question: which submissions in this set look like each other? None of them answers the question "was this written by a model?".

Why similarity tools struggle with AI code

A language model does not copy a single stored answer. It generates a new solution each time, and the wording, names and structure can vary from one request to the next. A 2022 study by Biderman and Raff tested this with GPT-J, an earlier open model, on introductory programming assignments. They reported that the generated solutions did not trigger suspicion from MOSS and were diverse in structure. Newer assistants are different models, and the study did not test ChatGPT, so treat it as evidence about the general problem rather than a measurement of today's tools.

Where similarity tools can still catch AI use is when several students submit closely matching generated code for the same prompt. In that case MOSS shows the overlap, but it still cannot say where the code came from.

What instructors use alongside MOSS

Because similarity is not the whole picture, courses that care about AI use tend to combine it with other checks: comparing your work with your earlier submissions, looking at Git history, asking you to explain or extend your solution, and sometimes running a dedicated AI code detector. Some commercial platforms, such as Codequiry, advertise AI detection alongside similarity checking; see our Codequiry comparison for what that service lists. Turnitin's AI writing detection, by contrast, is built for prose. See does Turnitin detect AI code for what its documentation says.

What this means for your own assignment

  • A MOSS match is not an accusation. Short tasks, standard algorithms and code built from the same lecture examples are often similar. The tool's own page says a person has to review every match.
  • No MOSS match does not mean nobody will ask. If your solution reads very differently from your usual style, a grader may notice regardless of any tool.
  • The best evidence is your process. Commits, drafts and the ability to explain your choices answer both similarity and AI questions.

Checking how your code reads

A similarity tool needs a whole class of submissions, so you cannot run one on your own work in any useful way. What you can do is check whether your code has the style patterns people associate with AI output. Paste it into the detector at the top of this page, read the reasons it lists, and compare them with how you really write. If it points out things like a comment on every line or a demo block the task never asked for, you will know what a grader might ask about, and you can be ready to explain it.

Read more

Frequently asked questions

Is MOSS an AI detector?

No. MOSS stands for Measure Of Software Similarity. Its official page describes it as a system for determining the similarity of programs. It compares the files it is given with each other and reports pairs that share code. It does not estimate whether code was written by a person or a language model.

Can MOSS flag code that came from ChatGPT?

Only indirectly. If several students submit closely matching AI-generated solutions, MOSS can show that those submissions are similar to each other. It cannot tell why they are similar, and a single AI-written solution that matches nobody else's will not stand out on similarity alone.

What about JPlag?

JPlag is an open-source tool that finds pairwise similarities among a set of programs and, according to its README, is designed to detect plagiarism and collusion even when the code is obfuscated. Like MOSS, it is a similarity tool. Its README does not describe AI detection.

Does Gradescope check for AI code?

Gradescope's Code Similarity report compares students' programs with each other within one assignment. Gradescope's guide says it does not automatically detect plagiarism; it shows how similar two programs are. It is not described as an AI detector.

My MOSS match is with a classmate I never worked with. What should I do?

Stay calm and gather your drafts and commit history. Short or very standard assignments often produce similar code, and MOSS's own page says its scores are not proof of plagiarism and that someone still has to look at the code. Explain how you built your solution and offer to walk through it.

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.