Copy/Paste Detector for Source Code

Agents copy. Reviewers miss it. Your build shouldn't. jscpd reads each of 224 languages by its own syntax, finds duplicated blocks and fails the build when they cross your threshold. Native Rust binary, no runtime: a 159 MB codebase scans in 3.4 seconds. Speaks MCP, ships an agent skill, and reports in a format LLMs can afford to read.
Terminal
$npx jscpd .
Node.js 20+, any OS, nothing installed globally
// Your code deserves better than copy/paste chaos
$jscpd./src
→ Finding duplicates...
✓ Found 90 clones · 54.4% duplication

Built for codebases where agents write code

Agents repeat helpers. Each diff reads fine on its own. Review can't catch it — a failing build can.
    Gate it
    jscpd . --threshold 3

    Runs in pre-commit and CI. "An agent will argue a comment, but a failing build just stops it." — @nark3d

    Set up the gate
    Let the agent check itself
    jscpd --mcp

    MCP server built into the binary. Claude, Cursor, or any MCP client checks for clones before writing more.

    MCP server docs
    Teach it to refactor
    npx skills add kucherenko/jscpd

    One skill: detect duplicates, propose the extraction, verify the count went down.

    Install the agent skill
    Feed the LLM, not the context window
    jscpd . --reporters ai

    About 79% fewer tokens than the default reporter. Pipe it straight into your agent loop.

    See the token benchmark
    Know where to start
    jscpd . --summary

    Files ranked by tokens, lines, or complexity, each with its duplication share. Refactor the worst first.

    Summary options

How teams wire it

Three places, one binary. Add any of them in under a minute.

Core

Detection that has been refined since 2013 — now a native Rust engine
    Since 2013

    A decade of refining the art of duplicate detection. Now rewritten in Rust for native performance — no Node.js runtime required.

    How detection works
    Speaks 224 Languages

    JavaScript, Python, Java, Go, Rust, C++, TypeScript, Ruby... If you can write it, we can scan it. Vue, Svelte, Astro, and Markdown cross-format detection too.

    View supported formats
    Blazingly Fast™

    A Rust engine with parallel detection across format groups. 159 MB codebase? 3.4 seconds. No Node.js runtime — just a single native binary.

    See benchmarks
    CLI-First Design

    One command to rule them all. Works everywhere — your laptop, CI/CD, that ancient Jenkins server nobody wants to touch.

    Get started
    Beautiful Reports

    HTML, JSON, XML, badges for your README. Make technical debt visible (and slightly embarrassing).

    Explore reporters
    Thresholds & Baselines

    Set a threshold and fail the build. Or commit a baseline and fail only on clones that are new since the last run.

    Configure thresholds
    Cross-Format Detection

    Vue SFC, Svelte, Astro, and Markdown files are tokenized per-block — a <script> in .vue can match a .ts file. And --cross-formats "js-ts" compares related formats in one pool, catching clones between .js and .ts files.

    Cross-format benchmark
    Git Blame

    --blame annotates every clone with the authors from git history, so you know who to ask before you refactor.

    All CLI options
    10M+ npm downloads / month

    One of the most trusted tools in the ecosystem. Join developers who rely on jscpd every day.

    View on npm

Integrations

Plug it into the tools you already run
    GitHub Action

    uses: kucherenko/jscpd@v5 — scans the repository, fails on threshold, and uploads SARIF to Code Scanning. No install step.

    GitHub Action docs
    Pre-commit Hooks

    Works with the pre-commit framework, Husky, or a plain shell hook in .git/hooks. Blocks the commit when duplication exceeds the threshold.

    Pre-commit docs
    SARIF / Code Scanning

    --reporters sarif writes a SARIF file that GitHub Code Scanning renders as inline alerts on the pull request.

    SARIF reporter docs
    GitLab CI

    The codeclimate reporter feeds GitLab Code Quality and openmetrics feeds its metrics reports, so duplication shows up on the merge request.

    GitLab CI docs
    Programmable

    Embed detection in your own tools with the Rust crates (cpd-finder, cpd-core), or drive the CLI and parse its JSON output from any language.

    View API documentation
    Trending Repos, Analyzed

    How much copy/paste ships in GitHub's trending repos? A daily pipeline runs jscpd v5 on each and publishes clone counts and duplication stats.

    See today's results

See It In Action

From chaos to clarity in seconds
# Scan your source code
$ jscpd ./src

Clone found (typescript):
 - src/utils.ts [10:1 - 25:3] (15 lines, 129 tokens)
    src/helpers.ts [5:1 - 20:3]

Clone found (typescript):
 - src/utils.ts [45:5 - 62:2] (17 lines, 178 tokens)
    src/components/Button.tsx [12:1 - 29:2]

Clone found (typescript):
 - src/hooks/useAuth.ts [1:1 - 34:2] (33 lines, 245 tokens)
    src/hooks/useSession.ts [1:1 - 34:2]

# ... more clones

Found 90 clones.
Detection time: 13ms

Fresh from GitHub Trending

Every day we run jscpd v5 over GitHub's trending repositories and publish how much copy/pasted code they ship — clone counts, duplication rates, and the largest duplicated blocks.

Developers Are Talking

Real mentions from the community on X
Horatio Thomas
Horatio Thomas@horatioecthomas

One of the most important tools you can add to CI when building with AI: github.com/kucherenko/jscpd

なかつがわ
なかつがわ@someone7140

へぇ 「jscpd v5 は Rust 製で速い。 26.7 万行 / 127ms。CI コストは実質ゼロ」

Nathan Broadbent
Nathan Broadbent@ndbroadbent

I highly recommend jscpd: github.com/kucherenko/jscpd Can’t live without this in my projects now

Peter Steinberger
Peter Steinberger@steipete

TIL: jscpd

mono
mono@_mono

npmjs.com/package/jscpd がDartコードのコピペ検出も対応してることを dart-lang/sdk の issue で知って試したら普通に動いた( ´・‿・`) 利用例: `jscpd . --pattern "**.dart" --min-lines 20`

Cory House
Cory House@housecor

One of my favorite tools during a code audit is jscpd. It detects copy/pasted code. In a codebase I’m currently reviewing, nearly half of the JS is duplicated! jscpd lists the specific duplicated spots so we can consider a cleanup.

Matt Pocock
Matt Pocock@mattpocockuk

Get AI to reduce duplicated code, reduce the jscpd number

Peter Steinberger
Peter Steinberger@steipete

I du regular sweeps with jscpd, ran a Socrates analysis yesterday and it was in the single digits. Could purge more, but writing overly generic code has its own problems.

nark3d
nark3d@nark3d

Same here, jscpd and the linter both sit in our CI gate. The thing that surprised me is it holds up better with agents than a review comment does. An agent will argue a comment, but a failing build just stops it, so the duplication never gets in.

高橋 俊 | CTO - ZENSHIN
高橋 俊 | CTO - ZENSHIN@suguru_takaha4

jscpd というコピペコードを検出する静的解析ツールいいかもしれない 結局コード品質を担保するにはAIに逐一指示するというアプローチよりは静的解析ツールとかでガチガチに縛ってしまった方が気持ち的に大胆にリファクタリングしやすい

Maximilian
Maximilian@_maxscn

just added a jscpd pre-commit hook and why did i not do this ages ago

Cory House
Cory House@housecor

Problem: You want to find copy/pasted code. Solution: jscpd. It finds copy/pasted code in over 150 languages. I just ran this command on a JS project: npx jscpd --ignore "**/node_modules/**" It found over 6,000+ lines of duplicated code.

Chris Cheney
Chris Cheney@_cheney

I break my specs into directed acyclic graphs in order to identify what work depends on other work and which tasks can be worked in parallel. I also run jscpd in pre-commit which helps cleanup duplicate code and interfaces. See my GitHub DAG project as an example of this

.
.@sjallatak

a good way to minimize slop in a typescript codebase is a forced validation command of knip, jscpd and linter of your choice. the more static validation you have the better.

HARUKI / UNCHAIN Community Lead
HARUKI / UNCHAIN Community Lead@haruki_web3

重複コードを消すツール! これも良さそう!!

matt sephton
matt sephton@gingerbeardman

Been experimenting with jscpd to spot similar code that I might be able to refactor, with the goal of simplifying and optimising and hopefully shave some bytes off my apps. Works with 150+ formats.

nark3d
nark3d@nark3d

I’ve got jscpd in the pre-commit hook for the same reason. It catches the duplicate before commit instead of in review, and review misses copy-paste because each diff reads fine alone. Gets more useful the more an agent repeats the same helper.

BudgetIce
BudgetIce@BudgetIce37955

知らせる層は knip(デッドコード)と jscpd(重複)。 こっちは止めずに、気づかせるだけの設定 あとは"入れて終わり"にしたくなかったので、既存のコードで溜まってた借金を返すEpicも立てて、子Issue10件で完走

harjot.co
harjot.co@harjjotsinghh

jscpd is genuinely one of those quietly-everywhere dev tools, congrats on the milestone. a small OSS project really can outlast flashier ones…

Cory House
Cory House@housecor

Problem: Your code base probably contains a lot of copy/pasted code, but it’s hard to find. Solution: jscpd jscpd is a command line tool that finds copy/pasted code and reports specific duplicated lines. Works for over 150 languages.

Contributors

jscpd is built by its contributors. Bug reports, formats, reporters, docs — every one of them is on this list.