What is jscpd?
jscpd is an open-source copy/paste detector for source code by Andrey Kucherenko, whose GitHub repository dates from 2013, released under the MIT licence. It finds duplicated code in 224 languages and fails the build when the share of duplication goes above the threshold you set. Version 5 is a Rust engine that ships as a self-contained binary with no runtime to install, while jscpd v4, the earlier TypeScript engine with a Node.js API, is still maintained on its own branch.
Each language is tokenized with its own comment and string rules, and a rolling Rabin-Karp hash finds repeated token sequences across files. A default run reports exact copies of at least 50 tokens and 5 lines. Opt-in flags find renamed clones that differ only in identifiers or literal values, near-miss clones with a few inserted or changed lines, and experimental semantic clones matched by a code embedding model that runs on the local CPU, so a scan makes no network call.
Install it with a shell script on macOS and Linux, PowerShell on Windows, or through npm, pip, cargo, Homebrew, Nix and Docker; prebuilt binaries cover macOS, Linux and Windows on arm64 and x64. Results go to 15 reporters, including console, HTML, JSON, SARIF, badge, Code Climate and a compact AI format. A GitHub Action uploads SARIF to GitHub Code Scanning, a pre-commit hook stops clones before they are committed, and the binary also runs as an MCP server for coding agents and a language server for editors.
Beyond duplicates, the same binary reports dead code in JavaScript, TypeScript and Python, ranks files by complexity, tracks duplication over git history and rolls the results into a 0-100 health score. GitHub Super Linter and MegaLinter bundle jscpd, and Codacy uses it for its duplication engine.
Key capabilities
- Exact clone detection A plain run reports identical token sequences of at least 50 tokens and 5 lines, ignoring whitespace, layout and comments.
- Renamed and near-miss clones Opt-in flags catch copies with new names or literal values, or with a few inserted or changed lines.
- CI quality gate A threshold fails the build, and a clone baseline tolerates legacy clones while failing on new ones.
- 15 reporters Output goes to console, HTML, JSON, XML, CSV, Markdown, SARIF, Code Climate, OpenMetrics, a badge or a compact AI format.
- GitHub Action The action installs the Rust engine, runs detection and uploads SARIF to GitHub Code Scanning.
- Editor diagnostics Jscpd --lsp runs as a language server for Neovim, Helix, Sublime Text, Emacs and JetBrains IDEs.
Where jscpd fits
- Language-aware tokenization All 224 formats use their own comment and string syntax, with the oxc parser for JavaScript and TypeScript.
- Semantic clones An experimental mode embeds functions with a code model and pairs ones that do the same job, even across languages.
- Boundaries Rules in .jscpd.json keep the code of a module, folder, file or method out of named places.
- Dead code and complexity Finds unused files, exports, symbols and imports in JavaScript, TypeScript and Python, and ranks files by complexity.
- History and health Charts duplication across a range of commits and shows a 0-100 health score with a grade.
- Codebase comparison Pairs the functions of two folders to track a port or check two implementations for parity.
- AI agents A built-in MCP server lets Claude, Cursor or Copilot check for existing code before writing it again.
Install
npm install -g jscpdReviews of jscpd
Be the first to share your experience with jscpd.
Write a review
Loading review form…
