Migration guide
Switching from fast-redact, pino redact, redact-secrets or deep-redact
Path and key-name redactors only hide what you listed. Keep your list, and let Flare Redact also catch the token pasted into a message, the password inside an error URL and the email in a free-text field.
paths carry over unchanged (users.*.password, items[*].card, headers["x-api-key"], plus ** for any depth), censor becomes mask and remove keeps its name. What changes is that every other string is read too.Option mapping
| You have | In Flare Redact |
|---|---|
paths: [...] (fast-redact, pino, @pinojs/redact) | paths: [...], same syntax, plus ** |
censor: '[REDACTED]' | mask: '[REDACTED]', or a function of the match |
remove: true | remove: true |
serialize (returns a JSON string) | redact() returns a copy; call JSON.stringify yourself |
list: ['email', 'password'] (deep-redact) | paths: ['**.email']; password is already a sensitive key |
| is-secret key rules (redact-secrets) | built in: db_password, accessToken, apiSecret and the rest |
Two differences in behaviour. Flare Redact never changes your object: it returns a copy and shares the parts it did not touch. And it masks every string it recognises, not only the listed ones, so output you compared byte for byte in a test may change where a value really was sensitive.
From fast-redact
// before
const fastRedact = require('fast-redact');
const redact = fastRedact({ paths: ['user.password', 'req.headers.authorization'], censor: '[REDACTED]' });
log(redact(event));
// after
const { compilePolicy } = require('flare-redact');
const policy = compilePolicy({ paths: ['user.password', 'req.headers.authorization'], mask: '[REDACTED]' });
log(JSON.stringify(policy.redact(event)));
fast-redact {"user":{"id":7,"password":"[REDACTED]"},"req":{"headers":{"authorization":"[REDACTED]","host":"api.example.com"}},"msg":"login failed for ada@example.com"}
flare-redact {"user":{"id":7,"password":"[REDACTED]"},"req":{"headers":{"authorization":"[REDACTED]","host":"api.example.com"}},"msg":"login failed for [REDACTED]"}
The listed paths come out the same; the email in msg is the difference. Use compilePolicy once at startup on a hot path, as you did with fastRedact(). CommonJS require works from 1.13.0, so Jest and older bundlers need no ESM setup.
From pino's redact option
pino's redact is fast-redact (or @pinojs/redact) inside pino. You can keep it and add value scanning next to it:
import pino from 'pino';
import { pinoRedact } from 'flare-redact/pino';
const logger = pino({
...pinoRedact(),
redact: ['user.password', 'req.headers.authorization'],
});
logger.info(event, 'login failed for ada@example.com');
pino redact only {"level":30,"user":{"id":7,"password":"[Redacted]"},"req":{"headers":{"authorization":"[Redacted]"}},"msg":"login failed for ada@example.com"}
with pinoRedact {"level":30,"user":{"id":7,"password":"[Redacted]"},"req":{"headers":{"authorization":"[Redacted]"}},"msg":"login failed for a***@***"}
Checked with pino 9.14. Or move the paths into pinoRedact({ paths: [...] }) so one policy covers both. Why the message needs its own hook.
From redact-secrets or is-secret
// before
const redact = require('redact-secrets')('[REDACTED]');
redact.map(config);
// after
const { redact } = require('flare-redact');
redact(config, { mask: '[REDACTED]' });
redact-secrets {"db_password":"[REDACTED]","accessToken":"[REDACTED]","max_tokens":"[REDACTED]","nextPageToken":"[REDACTED]","secret_name":"[REDACTED]","card":"[REDACTED]"}
flare-redact {"db_password":"[REDACTED]","accessToken":"[REDACTED]","max_tokens":4096,"nextPageToken":"CgkI2c3d","secret_name":"prod-db","card":"[REDACTED]"}
is-secret hides any key that contains token or secret, so a token count, a pagination cursor and the name of a secret disappear with the real credentials. Flare Redact looks at how a key ends (db_password, accessToken, api_secret) and keeps look-alikes such as max_tokens, nextPageToken, author and publicKey readable. The card is found by its Luhn checksum, wherever it is.
From deep-redact
// before
import { redact } from 'deep-redact';
redact(data, { list: ['email', 'password'], redactString: '[REDACTED]' });
// after
import { redact } from 'flare-redact';
redact(data, { paths: ['**.email'], mask: '[REDACTED]' });
deep-redact {"email":"[REDACTED]","password":"[REDACTED]","dontRedactMe":"123456","url":"https://example.com/r?this=test&password=[REDACTED]&email=[REDACTED]"}
flare-redact {"email":"[REDACTED]","password":"[REDACTED]","dontRedactMe":"123456","url":"https://example.com/r?this=test&[REDACTED]"}
**.email matches the key at any depth, which is what deep-redact's list does. One honest difference: deep-redact keeps each query parameter name, while Flare Redact masks the whole password=… assignment, including what follows it in the query.
Speed and coverage
One log record with nine planted secrets: two headers, two password fields, a card in an array, and four values inside strings (a key and an email in the message, a token in a URL query, a password in an error URL). Each library gets the configuration its README recommends, with every sensitive field listed where it takes a list.
| Library | Per record | Caught | Missed |
|---|---|---|---|
| fast-redact 3.5.0, 5 paths | 1.4 µs | 5 of 9 | every value inside a string |
| @pinojs/redact 0.4.0, 5 paths | 4.2 µs | 5 of 9 | every value inside a string |
| deep-redact 1.0.21, 5 keys | 15.5 µs | 5 of 9 | every value inside a string |
| veilit 1.0.1, defaults | 17.3 µs | 8 of 9 | the email in the message |
| Flare Redact 1.13.0, paths only | 7.8 µs | 5 of 9 | every value inside a string |
| Flare Redact 1.13.0, defaults | 41 µs | 9 of 9 | none |
Node 22.23 on an Apple A18 Pro; each figure is the middle of three runs of the script, and each run takes the median of 7 rounds of 20,000 records. Timings move by 10 to 20 percent between runs on a busy laptop. fast-redact is about 30 times faster, because it only touches the paths you name and compiles them to code; reading every value costs more. At 41 µs a record, one core still redacts over 20,000 log lines a second. The script is bench/object-redactors.mjs; run it on your own records before deciding.
In the browser and at the edge
flare-redact/lite is the same API without entity recognition (names and addresses found from name lists), at about 34 KB gzipped instead of 63 KB. Every secret detector and every pattern detector for emails, cards, phone numbers and IDs is still in it.
import { redact } from 'flare-redact/lite';
Next
See redacting secrets in Node.js logs for Winston, console and streams, or the path rules reference.