jscpd
Copy/paste detector for source code — a fast Rust CLI that finds duplicated blocks across 223 languages, writes reports in 15 formats and can fail CI when duplication grows.
This crate is the Rust engine behind jscpd (v5+). Full documentation lives at jscpd.dev.
Install
# or, without compiling (prebuilt release binaries via cargo-binstall):
cargo install jscpd installs two binaries with identical behaviour:
jscpd and cpd. The unrelated cpd crate on crates.io is not this
project; the crate name is jscpd.
Also available on npm (npm install -g jscpd), Homebrew (brew install jscpd)
and as prebuilt archives on the
GitHub releases page.
Usage
Config file
Options can also come from .jscpd.json in the scanned directory (or the
jscpd key of package.json, or --config <path>):
Reporters
Select one or more with --reporters (-r):
console, console-full, json, xml, csv, html, markdown, badge,
sarif, ai, xcode, threshold, silent, openmetrics, codeclimate
Baselines and CI gating
# Record the current state, then fail only on clones that were not in it.
# Or compare against a git ref without a stored baseline file
# (the ref's tree is scanned with the same options).
MCP server
jscpd --mcp . scans the given paths once, then serves the Model Context
Protocol over stdio, exposing check_duplication, get_statistics and
check_current_directory tools to MCP clients (Claude Code, Cursor, ...).
GitHub Action
- uses: kucherenko/jscpd@v5
with:
path: .
threshold: 5
reporters: console,sarif
Library use
The jscpd crate's library target is not a public API — it only exists to
share helpers with the crate's tests and may change in any release. For
programmatic use depend on the engine crates instead:
| Crate | Purpose |
|---|---|
cpd-finder |
File walking, orchestration, git blame — the entry point |
cpd-core |
Detection algorithm (Rabin–Karp rolling hash), data models |
cpd-tokenizer |
Language tokenization (223 formats) |
cpd-reporter |
Output formatting (15 reporters) |
use ;
let config = RunConfig ;
let result = run.unwrap;
println!;
println!;
Links
- Repository: https://github.com/kucherenko/jscpd
- Documentation: https://jscpd.dev
- Changelog: https://github.com/kucherenko/jscpd/blob/master/rust/CHANGELOG.md
License
MIT