npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

field-redactor

v1.5.0

Published

Utility for redacting PII from complex JSON objects for which simpler redaction tools are insufficient.

Downloads

368

Readme

FieldRedactor

A TypeScript library for redacting PII from nested JSON using regex key rules, object schemas (sibling-key patterns), and configurable redaction modes.

Install

npm install field-redactor
# or
yarn add field-redactor

Quick start

import { CustomObjectMatchType, FieldRedactor, FieldRedactorConfigBuilder } from 'field-redactor';

// Recommended: explicit rules via createSafe or the builder
const redactor = FieldRedactorConfigBuilder.create()
  .shallow(/email/i, /password/i)
  .remove(/authKey/i)
  .schema(
    { name: CustomObjectMatchType.Ignore, type: CustomObjectMatchType.Ignore, value: 'name' },
    { name: 'metadata-entry' }
  )
  .buildSafeRedactor();

const result = redactor.redactSync({
  email: '[email protected]',
  authKey: 'secret',
  metadata: [{ name: 'email', type: 'String', value: '[email protected]' }]
});

redact() / redactSync() leave the input untouched by default (copy-on-write). Primitives, Date, and null/undefined at the root are returned unchanged.

Preview changes with dryRun

const { result, report } = redactor.dryRunSync(payload);
// report.redactedPaths, report.deletedPaths, report.matchedSchemas, report.pathRules

Start here

Do you know which JSON keys are always sensitive?
  ├─ yes → Shallow / Deep / Opaque / Remove (see secret key modes guide)
  └─ only sometimes → shaped objects like { name, value }? → Schema rules (see metadata guide)

Precedence: Schema → Opaque → Deep → Remove → Shallow → Value-pattern

| Concept | Config field | | --- | --- | | Shallow | secretKeys | | Deep | deepSecretKeys | | Opaque | fullSecretKeys | | Remove | deleteSecretKeys | | Schema | customObjects |

Use FieldRedactor.createSafe({ ... }) or FieldRedactorConfigBuilder so you never accidentally redact every field. new FieldRedactor() without rules still redacts all values (legacy default).

Documentation

| Guide | Description | | --- | --- | | Secret key modes | Shallow, Deep, Opaque, Remove with examples | | Metadata redaction | { name, value } schemas and sibling-key rules | | Anti-patterns | Common config mistakes and fixes | | Value-pattern redaction | Detect PII in free-text field values | | Configuration reference | Full option table, API, presets, validation | | Migration 1.2 → 1.5 | Upgrade from the previous npm line | | Release notes | Per-version notes for every published tag |

API surface

import {
  FieldRedactor,
  FieldRedactorConfigBuilder,
  FieldRedactorConfigurationError,
  FieldRedactorError,
  presets,
  validateFieldRedactorConfig
} from 'field-redactor';

import type { DryRunPathRule, RedactionRuleLabel, MatchedSchemaReport } from 'field-redactor';
  • Sync: redactSync(), redactInPlaceSync(), dryRunSync()
  • Async: redact(), redactInPlace(), dryRun() (sync path when no async-only redactor)
  • Presets: presets.loggingMetadata(), presets.applicationLogging(), presets.keyValueEntries()

Why this library exists

Many log payloads encode sensitivity in sibling fields rather than key names — for example { name: "email", value: "[email protected]" }. FieldRedactor matches object schemas and applies rules based on a sibling's value. See Metadata redaction for the full pattern.