OPEN SOURCE · MIT · NPM

keysnitch: find leaked keys in any text

A JavaScript library that reads a string and tells you where the credentials are: an Atlassian API token in a Jira comment, a Google key in a URL, a database password in a pasted .env file.

Why we built it

On 1 November 2026 we put 1,400 fake leaks through the two scanners we had: Secret Sentinel, then built on secretlint, and our free leak checker. Secret Sentinel found none of 50 Atlassian API tokens. In an app for Jira and Confluence, that is the one key it must not miss. Neither scanner found a password in a .env line, in curl -u or in a sentence. So we wrote one engine for both, and opened it.

What it finds

Every rule, by company: docs/rules.md.

Install and use

npm install keysnitch

Node 24 or newer. The code is plain TypeScript with no Node APIs, so it also runs in browsers, workers, serverless functions and Atlassian Forge.

import { mask, scan } from "keysnitch";

const { findings } = scan(text);
for (const finding of findings) {
  const value = text.slice(finding.start, finding.end);
  console.log(finding.vendor, finding.label, mask(value));
}
// GitHub  GitHub personal access token  ghp_****x9Q2

A finding is a range: where the secret starts and ends, the company, the name and a severity. The value itself never lands in a finding, an error or a log. When rules overlap, one finding covers all of them, so nothing stays readable after you redact. You can add your own rules with defineRule(), which refuses any pattern that could make matching slow.

How it compares

The same 1,400 fake leaks in 28 shapes: random values in the vendors' published formats, pasted the way people paste them into tickets and pages.

ScannerFound
Secret Sentinel on secretlint, 1 Nov 2026898
Our free leak checker, 47 formats, 1 Nov 20261,047
keysnitch 0.1.1 from npm, 6 Nov 20261,392

Read the last number with care: keysnitch was written after this test, by people who knew its shapes, so the result is not blind. It misses 8 passwords in a table column that are made only of letters. That is on purpose: a word like "regenerate" in a table is not a password. Every shape, with the method: our secret sprawl test.

Where it runs today

Limits

keysnitch is a safety net, not a guarantee. It finds credentials with a known shape. It does not guess random strings by entropy, so a password with no word next to it, or a token of an unknown format, is not found. It scans text only: no files, archives or images. It does not look for personal data such as card numbers. That is a separate layer in Secret Sentinel.

Further reading

Frequently asked questions

How is keysnitch different from gitleaks?

gitleaks is a command-line tool that scans git history and files. keysnitch is a library that scans a string you give it, inside any JavaScript runtime: a browser, a worker, a serverless function or an Atlassian Forge app. keysnitch has every gitleaks rule that applies to text, so it finds at least what gitleaks finds by pattern.

Can a hostile text make a scan slow?

No. Every rule passes a safety check before it can run: each repeat has an upper bound and backtracking is limited, so scans stay linear in the length of the text (no ReDoS). defineRule() refuses a pattern that could be slow, with UnsafePatternError.

Does keysnitch keep or send the secrets it finds?

No. A finding is a start and an end offset with the rule name. The value never lands in a finding, an error or a log, and the library makes no network requests.

Does it find card numbers or other personal data?

No. keysnitch finds credentials only. Secret Sentinel adds its own optional rules for card numbers, IBANs and US Social Security numbers on top of it. Names, e-mail addresses and phone numbers are not detected by either.

Does it guess random strings by entropy?

No. It finds credentials with a known shape: a vendor prefix, or a value written next to a word such as password, token or secret. A random string with nothing around it is not reported. That keeps false positives low, and it is the main limit to plan around.