Getting Started

Introduction

Welcome to jscpd documentation.

Welcome to jscpd, a powerful copy/paste detector for programming source code that supports 224 languages and formats.

What is jscpd?

jscpd is a tool that helps you find duplicated blocks in programming source code. Copy/paste is a common source of technical debt in software projects, and jscpd helps you identify and eliminate these duplications.

jscpd reads code the way its language defines it, not as plain text. Each of the 224 formats is tokenized with its own comment and string syntax, JavaScript and TypeScript go through the oxc parser, and Vue, Svelte, Astro, Markdown and Razor files are split into their embedded languages first. Identifiers, keywords and literals are classified, which is what lets the renamed-clone options replace names while keeping keywords in place.

On that token stream the tool uses the Rabin-Karp rolling hash algorithm for efficient searching of duplications across large codebases. The engine is implemented in Rust and ships as a self-contained binary. See How Detection Works for the full pipeline.

jscpd v5

jscpd v5 is a complete Rust rewrite — a self-contained native binary with no Node.js runtime required. It ships 15 reporters, OXC-based JS/TS tokenization, parallel detection across format groups, and a built-in MCP server (cpd --mcp).

See the Changelog for the full release history. Coming from the TypeScript version? See the Migration Guide — v4 itself is described on the v4 page and lives on the master-v4 branch.

Key Features

224 Languages

Supports JavaScript, TypeScript, Python, Java, C++, Go, Rust, and many more — including cross-format detection for Vue, Svelte, Astro, and Markdown.

Language-Aware

Every format is tokenized by its own syntax, JavaScript and TypeScript by a real parser. Comments, strings, keywords and decorators are what the language says they are.

Blazingly Fast

A Rust engine with parallel detection and near-zero startup cost. Scans massive codebases in seconds, small ones in milliseconds.

CLI-First + Rust API

A single native binary for the command line, plus Rust crates (cpd-finder, cpd-core) for programmatic use.

15 Reporters

Generate reports in console, console-full, HTML, JSON, XML, CSV, Markdown, SARIF, AI, badge, xcode, threshold, and silent formats.

AI-Ready

Compact ai reporter saves ~79% tokens. MCP server for AI assistants. Agent skill for automatic refactoring.

Cross-Format Detection

Vue SFC, Svelte, Astro, and Markdown files are tokenized per-block — a <script> in .vue matches .ts files.

Packages

PackageDescription
jscpdMain binary — npm install -g jscpd or cargo install jscpd
cpdLightweight alias — same binary, shorter command
cpd-coreRust crate — core detection algorithm
cpd-tokenizerRust crate — source code tokenizer
cpd-finderRust crate — file walking, orchestration, git blame
cpd-reporterRust crate — output reporters

Quick Example

# Install the native binary via npm
npm install -g jscpd

# Or via cargo
cargo install jscpd

# Scan a directory
jscpd /path/to/source

Ready to get started? Head to the Installation guide, or the Migration Guide if you're upgrading from v4.