jscpd
Copy/paste detector for programming source code. Finds duplicated code in 224 languages, reports as HTML/JSON/SARIF/Markdown, fails CI over a duplication threshold. Rust engine, self-contained binary.
Last updated a month ago by apk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install jscpd 
SYNC missed versions from official npm registry.

jscpd — Copy/Paste Detector

npm version npm downloads license crates.io homepage

jscpd v5 is the Rust engine — a self-contained binary, no Node.js runtime. The TypeScript engine (v4: Node.js API, LevelDB/Redis stores) is maintained on the master-v4 branch and published as jscpd@4.

Copy/paste detector for programming source code. Supports 224 language formats, 15 output reporters, and per-line author attribution via git blame. Prebuilt binaries for 8 platforms — no Node.js runtime required.

Packages

Package Installs Use it when
jscpd jscpd Default install; the jscpd command
cpd cpd Shorter command name only
jscpd (crates.io) jscpd + cpd Rust-native install; both binaries

The npm jscpd package installs a single jscpd command that runs the same Rust binary as cpd. For the shorter cpd alias on npm, install the separate cpd package.

Install

# npm — installs the jscpd command
npm install -g jscpd

# crates.io — installs both jscpd and cpd binaries
cargo install jscpd

# Nix — run without installing
nix run github:kucherenko/jscpd -- /path/to/code

# Nix — install permanently
nix profile install github:kucherenko/jscpd

# Homebrew (macOS/Linux)
brew install jscpd

Prebuilt binaries for: macOS arm64/x64, Linux arm64/x64 (glibc + musl), Windows arm64/x64.

Quick Start

jscpd .                                       # scan current directory
jscpd ./src ./lib                             # scan specific paths
jscpd . --min-tokens 30 --min-lines 3         # tune detection sensitivity
jscpd . --blame --reporters console-full      # git blame, side-by-side authors
jscpd . --reporters json,html                 # write report files
jscpd . --threshold 10                        # fail CI if >10% duplicated
jscpd --list                                  # list all supported formats

Options

Flag Short Default Description
--min-tokens -k 50 Minimum tokens in a clone
--min-lines -l 5 Minimum lines in a clone
--max-lines -x — Maximum lines per duplicate block
--max-size -z — Skip files larger than SIZE (e.g. 1mb)
--mode -m mild Detection mode: mild, weak, strict
--skip-comments — — Alias for --mode weak
--format -f all Comma-separated formats to check
--ignore -i — File-level glob patterns to ignore (comma-separated); they match the whole path, so use **/node_modules/** for a directory
--ignore-pattern — — Code-level regex patterns; tokens overlapping a match are skipped during detection, e.g. //\\s*cpd-disable (comma-separated)
--reporters -r console Comma-separated reporters
--output -o report Output directory for file reporters
--config -c — Path to .jscpd.json config file
--threshold -t — Max duplication % before exit 1
--blame -b — Enrich clones with git blame data
--workers — auto Worker threads for parallel scan
--skip-local — — Skip clones within the same directory
--absolute -a — Use absolute paths in reports
--silent -s — Suppress console output
--list — — List all supported formats and exit

Full options: docs/rust.md.

Reporters

Reporter Output
console Clone list + statistics table (default)
console-full Source snippets; with --blame shows side-by-side author comparison
json report/jscpd-report.json
html report/jscpd-report.html
sarif report/jscpd-report.sarif (GitHub Code Scanning)
ai Token-efficient output for LLM pipelines
badge report/jscpd-badge.svg + report/jscpd-lines-badge.svg

Also: xml, csv, markdown, codeclimate, openmetrics, xcode, threshold, silent (15 total).

Config File

Create .jscpd.json in your project root:

{
  "minTokens": 30,
  "minLines": 3,
  "format": ["javascript", "typescript", "python"],
  "ignore": ["**/node_modules/**", "**/dist/**", "**/*.min.js"],
  "reporters": ["console", "json"],
  "output": "report",
  "threshold": 5,
  "blame": false
}

Supported Formats

224 formats including: JavaScript, TypeScript, Python, Go, Rust, Java, C/C++, C#, Ruby, PHP, Swift, Kotlin, Scala, Vue SFC, Svelte, Astro, Markdown, SQL, HTML, CSS, Bash, Dart, Lua, R, Haskell, Clojure, Elixir, Apex, CFML, and 200+ more.

Run jscpd --list for the full list, or see FORMATS.md.

Cross-format detection: Vue SFC (.vue), Svelte (.svelte), Astro (.astro), and Markdown files are tokenized per-block, enabling duplicate detection across file types.

CI

GitHub Action — installs the Rust engine, runs detection, uploads SARIF to GitHub Code Scanning:

- uses: kucherenko/jscpd@v5
  with:
    threshold: 5

Pre-commit hook (Husky):

echo 'npx jscpd --threshold 5 --reporters console,silent .' > .husky/pre-commit

Full CI/pre-commit guide: docs/ci-and-hooks.md.

Programmatic Usage (Rust)

use cpd_finder::orchestrate::{RunConfig, run};

let config = RunConfig {
    paths: vec!["./src".into()],
    min_tokens: 50,
    ..Default::default()
};

let result = run(&config).unwrap();
println!("Found {} clones", result.clones.len());
println!("Analyzed {} files", result.statistics.total.sources);

Coming from jscpd v4

Flags, config file and reporters are the same. The differences:

Feature jscpd v4 (Node.js) jscpd v5 (Rust)
--store (LevelDB/Redis) Persistent store for large repos Not supported (flag ignored with a warning)
Programming API jscpd() Promise, detectClones() Rust crate API; no Node.js API
--reporters All v4 reporters All except full (use console-full)
Output filenames jscpd-report.json, html/ dir jscpd-report.* prefix

Full table: docs/rust.md. jscpd v4 lives on the master-v4 branch.

Architecture

jscpd (CLI binary)
 ├── cpd-core      — Detection algorithm (Rabin-Karp rolling hash)
 ├── cpd-tokenizer — Language tokenization (224 formats)
 ├── cpd-finder    — File walking, orchestration, git blame
 └── cpd-reporter  — Output formatting (15 reporters)

Links

License

MIT

Current Tags

  • 3.3.0-alpha.8                                ...           canary (7 years ago)
  • 5.4.2                                ...           latest (a month ago)
  • 4.3.0                                ...           latest-4 (3 months ago)
  • 1.0.0-rc.6                                ...           prerelease (8 years ago)
  • 4.0.0                                ...           rc (3 years ago)

190 Versions

  • 5.4.2                                ...           a month ago
  • 5.4.1                                ...           2 months ago
  • 5.4.0                                ...           2 months ago
  • 5.3.3                                ...           2 months ago
  • 5.3.2                                ...           2 months ago
  • 5.3.1                                ...           2 months ago
  • 5.3.0                                ...           2 months ago
  • 5.2.1                                ...           2 months ago
  • 5.2.0                                ...           3 months ago
  • 5.1.2                                ...           3 months ago
  • 5.1.1                                ...           3 months ago
  • 5.1.0                                ...           3 months ago
  • 5.0.16                                ...           3 months ago
  • 4.3.0                                ...           3 months ago
  • 5.0.15                                ...           3 months ago
  • 5.0.14                                ...           4 months ago
  • 5.0.12                                ...           5 months ago
  • 5.0.11                                ...           5 months ago
  • 5.0.10                                ...           5 months ago
  • 5.0.9                                ...           5 months ago
  • 5.0.8                                ...           6 months ago
  • 5.0.7                                ...           6 months ago
  • 5.0.6                                ...           6 months ago
  • 5.0.5                                ...           6 months ago
  • 5.0.4                                ...           6 months ago
  • 4.2.5                                ...           6 months ago
  • 4.2.4                                ...           6 months ago
  • 4.2.3                                ...           6 months ago
  • 4.2.2                                ...           6 months ago
  • 4.2.1                                ...           6 months ago
  • 4.2.0                                ...           6 months ago
  • 4.1.1                                ...           7 months ago
  • 4.1.0                                ...           7 months ago
  • 4.0.9                                ...           8 months ago
  • 4.0.8                                ...           10 months ago
  • 4.0.7                                ...           a year ago
  • 4.0.6 [deprecated]           ...           a year ago
  • 4.0.5                                ...           2 years ago
  • 4.0.4                                ...           2 years ago
  • 4.0.3                                ...           2 years ago
  • 4.0.2                                ...           2 years ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.5.10 [deprecated]           ...           3 years ago
  • 3.5.9 [deprecated]           ...           4 years ago
  • 3.5.8 [deprecated]           ...           4 years ago
  • 3.5.6 [deprecated]           ...           4 years ago
  • 3.5.5 [deprecated]           ...           4 years ago
  • 3.5.4 [deprecated]           ...           4 years ago
  • 3.5.3 [deprecated]           ...           4 years ago
  • 3.5.1 [deprecated]           ...           4 years ago
  • 3.5.0 [deprecated]           ...           4 years ago
  • 3.4.5 [deprecated]           ...           5 years ago
  • 3.4.2 [deprecated]           ...           5 years ago
  • 3.4.1 [deprecated]           ...           5 years ago
  • 3.3.26 [deprecated]           ...           6 years ago
  • 3.3.25 [deprecated]           ...           6 years ago
  • 3.3.24 [deprecated]           ...           6 years ago
  • 3.3.23 [deprecated]           ...           6 years ago
  • 3.3.22 [deprecated]           ...           6 years ago
  • 3.3.21 [deprecated]           ...           6 years ago
  • 3.3.20 [deprecated]           ...           6 years ago
  • 3.3.19 [deprecated]           ...           6 years ago
  • 3.3.17 [deprecated]           ...           6 years ago
  • 3.3.16 [deprecated]           ...           6 years ago
  • 3.3.14 [deprecated]           ...           6 years ago
  • 3.3.13 [deprecated]           ...           6 years ago
  • 3.3.11 [deprecated]           ...           6 years ago
  • 3.3.9 [deprecated]           ...           6 years ago
  • 3.3.8 [deprecated]           ...           6 years ago
  • 3.3.3 [deprecated]           ...           6 years ago
  • 3.3.2 [deprecated]           ...           6 years ago
  • 3.3.1 [deprecated]           ...           6 years ago
  • 3.3.0-rc.10 [deprecated]           ...           6 years ago
  • 3.3.0-rc.9 [deprecated]           ...           6 years ago
  • 3.3.0-rc.8 [deprecated]           ...           6 years ago
  • 3.3.0-rc.7 [deprecated]           ...           6 years ago
  • 3.3.0-rc.6 [deprecated]           ...           7 years ago
  • 3.3.0-rc.5 [deprecated]           ...           7 years ago
  • 3.3.0-rc.4 [deprecated]           ...           7 years ago
  • 3.3.0-rc.3 [deprecated]           ...           7 years ago
  • 3.3.0-alpha.8 [deprecated]           ...           7 years ago
  • 3.3.0-alpha.3 [deprecated]           ...           7 years ago
  • 3.3.0-alpha.2 [deprecated]           ...           7 years ago
  • 3.2.1 [deprecated]           ...           7 years ago
  • 3.2.0 [deprecated]           ...           7 years ago
  • 3.1.0 [deprecated]           ...           7 years ago
  • 3.0.1 [deprecated]           ...           7 years ago
  • 3.0.0 [deprecated]           ...           7 years ago
  • 2.0.16 [deprecated]           ...           7 years ago
  • 2.0.15 [deprecated]           ...           8 years ago
  • 2.0.14 [deprecated]           ...           8 years ago
  • 2.0.13 [deprecated]           ...           8 years ago
  • 2.0.12 [deprecated]           ...           8 years ago
  • 2.0.11 [deprecated]           ...           8 years ago
  • 2.0.10 [deprecated]           ...           8 years ago
  • 2.0.9 [deprecated]           ...           8 years ago
  • 2.0.8 [deprecated]           ...           8 years ago
  • 2.0.7 [deprecated]           ...           8 years ago
  • 2.0.6 [deprecated]           ...           8 years ago
  • 2.0.5 [deprecated]           ...           8 years ago
  • 2.0.4 [deprecated]           ...           8 years ago
  • 2.0.3 [deprecated]           ...           8 years ago
  • 2.0.2 [deprecated]           ...           8 years ago
  • 2.0.1 [deprecated]           ...           8 years ago
  • 2.0.0 [deprecated]           ...           8 years ago
  • 1.2.3 [deprecated]           ...           8 years ago
  • 1.2.2 [deprecated]           ...           8 years ago
  • 1.2.1 [deprecated]           ...           8 years ago
  • 1.2.0 [deprecated]           ...           8 years ago
  • 1.1.0 [deprecated]           ...           8 years ago
  • 1.0.3 [deprecated]           ...           8 years ago
  • 1.0.2 [deprecated]           ...           8 years ago
  • 1.0.1 [deprecated]           ...           8 years ago
  • 1.0.0 [deprecated]           ...           8 years ago
  • 1.0.0-rc.6 [deprecated]           ...           8 years ago
  • 1.0.0-rc.5 [deprecated]           ...           8 years ago
  • 1.0.0-rc.4 [deprecated]           ...           8 years ago
  • 0.6.25 [deprecated]           ...           8 years ago
  • 1.0.0-rc.3 [deprecated]           ...           8 years ago
  • 1.0.0-rc.2 [deprecated]           ...           8 years ago
  • 1.0.0-rc.0 [deprecated]           ...           8 years ago
  • 0.6.24 [deprecated]           ...           8 years ago
  • 0.6.23 [deprecated]           ...           8 years ago
  • 1.0.0-alpha.2 [deprecated]           ...           8 years ago
  • 1.0.0-alpha.1 [deprecated]           ...           8 years ago
  • 1.0.0-alpha.0 [deprecated]           ...           8 years ago
  • 0.6.22 [deprecated]           ...           8 years ago
  • 0.6.21 [deprecated]           ...           8 years ago
  • 0.6.20 [deprecated]           ...           8 years ago
  • 0.6.19 [deprecated]           ...           8 years ago
  • 0.6.18 [deprecated]           ...           9 years ago
  • 0.6.17 [deprecated]           ...           9 years ago
  • 0.6.15 [deprecated]           ...           9 years ago
  • 0.6.14 [deprecated]           ...           9 years ago
  • 0.6.13 [deprecated]           ...           9 years ago
  • 0.6.12 [deprecated]           ...           9 years ago
  • 0.6.11 [deprecated]           ...           10 years ago
  • 0.6.10 [deprecated]           ...           10 years ago
  • 0.6.9 [deprecated]           ...           10 years ago
  • 0.6.8 [deprecated]           ...           10 years ago
  • 0.6.7 [deprecated]           ...           10 years ago
  • 0.6.6 [deprecated]           ...           10 years ago
  • 0.6.5 [deprecated]           ...           10 years ago
  • 0.6.4 [deprecated]           ...           10 years ago
  • 0.6.3 [deprecated]           ...           10 years ago
  • 0.6.2 [deprecated]           ...           10 years ago
  • 0.6.1 [deprecated]           ...           11 years ago
  • 0.6.0 [deprecated]           ...           11 years ago
  • 0.5.4 [deprecated]           ...           11 years ago
  • 0.5.3 [deprecated]           ...           11 years ago
  • 0.5.2 [deprecated]           ...           11 years ago
  • 0.5.1 [deprecated]           ...           11 years ago
  • 0.5.0 [deprecated]           ...           11 years ago
  • 0.4.3 [deprecated]           ...           11 years ago
  • 0.4.2 [deprecated]           ...           11 years ago
  • 0.4.1 [deprecated]           ...           11 years ago
  • 0.4.0 [deprecated]           ...           12 years ago
  • 0.3.6 [deprecated]           ...           12 years ago
  • 0.3.5 [deprecated]           ...           12 years ago
  • 0.3.4 [deprecated]           ...           12 years ago
  • 0.3.3 [deprecated]           ...           12 years ago
  • 0.3.2 [deprecated]           ...           13 years ago
  • 0.3.1 [deprecated]           ...           13 years ago
  • 0.3.0 [deprecated]           ...           13 years ago
  • 0.2.19 [deprecated]           ...           13 years ago
  • 0.2.18 [deprecated]           ...           13 years ago
  • 0.2.17 [deprecated]           ...           13 years ago
  • 0.2.16 [deprecated]           ...           13 years ago
  • 0.2.15 [deprecated]           ...           13 years ago
  • 0.2.14 [deprecated]           ...           13 years ago
  • 0.2.13 [deprecated]           ...           13 years ago
  • 0.2.12 [deprecated]           ...           13 years ago
  • 0.2.11 [deprecated]           ...           13 years ago
  • 0.2.10 [deprecated]           ...           13 years ago
  • 0.2.9 [deprecated]           ...           13 years ago
  • 0.2.8 [deprecated]           ...           13 years ago
  • 0.2.7 [deprecated]           ...           13 years ago
  • 0.2.6 [deprecated]           ...           13 years ago
  • 0.2.4 [deprecated]           ...           13 years ago
  • 0.2.3 [deprecated]           ...           13 years ago
  • 0.2.1 [deprecated]           ...           13 years ago
  • 0.2.0 [deprecated]           ...           13 years ago
  • 0.1.7 [deprecated]           ...           13 years ago
  • 0.1.6 [deprecated]           ...           13 years ago
  • 0.1.5 [deprecated]           ...           13 years ago
  • 0.1.4 [deprecated]           ...           13 years ago
  • 0.1.3 [deprecated]           ...           13 years ago
  • 0.1.2 [deprecated]           ...           13 years ago
  • 0.1.1 [deprecated]           ...           13 years ago
Maintainers (1)
Downloads
Total 527
Today 1
This Week 26
This Month 286
Last Day 0
Last Week 9
Last Month 33
Dependencies (0)
None
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE