# jscpd

> Copy/paste detector for 224 source formats with a Rust engine. Also reports dead code, complexity, git-history duplication trends, and a health score.

Stars: 6.5k · Language: Rust · License: MIT · Categories: Dev Tools

- Repository: https://github.com/kucherenko/jscpd
- Website: https://jscpd.dev
- Page: https://www.trmn.sh/tools/jscpd

## Install

- Homebrew: `brew install jscpd`
- npm: `npm install -g jscpd`
- Cargo: `cargo install jscpd`

## Overview

jscpd is a duplicate code detector written in Rust and shipped as a self-contained binary. It tokenizes each of its 224 supported formats using that language's own comment and string rules, then finds repeated token sequences across files with a rolling Rabin-Karp hash. JavaScript, TypeScript, JSX and TSX are parsed with the oxc parser, and embedded languages are extracted from Vue, Svelte, Astro, Markdown and Razor files. Run it with `jscpd /path/to/code`.

By default it reports exact clones. Opt-in flags extend detection: `--ignore-identifiers`, `--ignore-literals` and `--ignore-annotations` find Type-2 clones that differ only in names or values. `--max-gap-lines N` and `--similarity 0.85` find Type-3 near-miss clones. The experimental `--semantic` flag uses a code embedding model to find functions that do the same thing written differently (Type-4). `--compare dirA/ dirB/` pairs functions across two codebases to show what has no counterpart in the other. Results can be filtered by kind with `--kind`, and `--skip-local` and `--skip-isolated` limit reports to cross-folder or cross-team duplication in monorepos.

Beyond duplication, it has `--dead-code` (unused files, exports, declarations and imports in JavaScript, TypeScript and Python), `--complexity` and `--summary` for ranking files and folders, `--history` for duplication trends across a git commit range, `--blame` for author comparison, `--dashboard`, and `--health` for a single 0-100 score. There are 15 reporters, including console, json, xml, csv, html, markdown, badge, sarif, codeclimate, openmetrics and an `ai` reporter. A baseline mode (`--baseline`, `--fail-on-new-clones`) fails CI only on newly introduced clones.

Integrations include a GitHub Action that uploads SARIF to Code Scanning, GitLab-compatible report artifacts, pre-commit hooks, an LSP server (`jscpd --lsp`) for Neovim, Helix, Sublime Text, Emacs and JetBrains IDEs, and an MCP server and agent skills for AI agents. It targets developers and teams who want to gate CI on duplication or track code quality over time. It installs through npm, PyPI, Cargo, Homebrew, Nix and Docker.

### Installation

```bash
# via Homebrew
brew install jscpd
```

```bash
# via npm
npm install -g jscpd
```

```bash
# via Cargo
cargo install jscpd
```

## Alternatives

- [pastel](https://www.trmn.sh/tools/pastel.md): Command-line tool to generate, analyze, convert and manipulate colors across multiple formats and color spaces (Rust, 6.5k stars)
- [tealdeer](https://www.trmn.sh/tools/tealdeer.md): Fast Rust implementation of tldr providing simplified, example-based manual pages for command-line tools (Rust, 6.6k stars)
- [zizmor](https://www.trmn.sh/tools/zizmor.md): Static analysis tool that finds and fixes security issues in CI/CD configurations, including GitHub Actions workflows, Dependabot, and pre-commit. (Rust, 6.8k stars)
- [watchexec](https://www.trmn.sh/tools/watchexec.md): File watcher that runs commands when files change, with .gitignore support and cross-platform filesystem monitoring (Rust, 7.3k stars)
- [sd](https://www.trmn.sh/tools/sd.md): Find and replace CLI tool with regex support, string-literal mode, and faster performance than sed (Rust, 7.4k stars)

---

Canonical: https://www.trmn.sh/tools/jscpd
