On this page
Sommatic Docs
Open portal

Redact PII

Redacts Personally Identifiable Information (PII) from text or JSON objects to ensure data privacy and compliance.

View as Markdown
Open in
Identity Available pii.redact Version 1.0.0 Execution: sync

Masks or removes PII in the node input item with regular expressions: email addresses and card numbers by default, plus US-style SSN and phone patterns or your own patterns when listed in rules.

How it works

  1. Takes the node input item (the previous node output) as the content to redact. The input field configured on the node is not used.
  2. Serializes the item to a JSON string.
  3. Applies each entry of rules in order: a preset name (email, credit_card, ssn, phone) or, otherwise, the text compiled as a regular expression with the g flag. Invalid patterns are skipped without notice.
  4. Replaces every match with * repeated to the match length (strategy: "mask", the default) or with nothing ("remove").
  5. Parses the string back to JSON and returns it under result on out.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-redact-ticket",
  "label": "Redact ticket PII",
  "operator_slug": "pii.redact",
  "operator_version": "1.0.0",
  "config": {
    "input": "{{ $json }}",
    "strategy": "mask",
    "rules": [
      "email",
      "credit_card",
      "phone"
    ]
  }
}

Configuration

input object Required

Text or JSON Object to redact

strategy string Optional

Default: mask

Allowed values: maskremove

rules array Optional

Regex or Predefined Types

Default: ["email","credit_card"]

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

input
Ignored: the runtime replaces it with the node input item. To redact only part of the data, shape the item first with a previous node such as data.transform.
rules
Default ["email", "credit_card"]: ssn and phone apply only when listed. Presets: email ([email protected]), credit_card (16 digits in four groups of four, optionally separated by - or a space), ssn (123-45-6789), phone (10 digits as 555-123-4567, 555.123.4567 or 5551234567; no country code, parentheses or spaces). Patterns check format only, with no checksum. Custom patterns are case-sensitive and run over the serialized JSON, so they also match object keys.
strategy
Any value other than remove masks. Masking keeps the original length; remove leaves an empty string in place of the match.

Output ports

out default

The item was redacted and parsed back.

Data
{
  "result": {
    "customer": "Jane",
    "email": "****************",
    "card": "*******************",
    "note": "call 555-123-4567"
  }
}
error

rules is not an array, or a replacement broke the serialized JSON.

Data
{
  "error": "rules.forEach is not a function"
}

In expressions

What a later node can read from this node's output with $("Redact PII").item.json.<path> (write your node's label instead of Redact PII). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("Redact PII").item.json.resultobject= {…}Redacted content
$("Redact PII").item.json.result.customerstringNot suggested by the editor= "Jane"—
$("Redact PII").item.json.result.emailstringNot suggested by the editor= "****************"—
$("Redact PII").item.json.result.cardstringNot suggested by the editor= "*******************"—
$("Redact PII").item.json.result.notestringNot suggested by the editor= "call 555-123-4567"—

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
rules.forEach is not a function error rules is a string or an object. Pass an array, for example ["email", "phone"].
Unexpected token '*', "<serialized item>" is not valid JSON error A pattern matched a JSON number (for example a phone stored as 5551234567) or JSON syntax (quotes, braces, colons), so the text no longer parses. Store such values as strings or anchor custom patterns to value content. The message includes a fragment of the serialized item.

Input contract

input object Required
strategy string Optional
rules array Optional

Output contract

result object Optional

Redacted content

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "pii.redact",
  "name": "Redact PII",
  "category": "identity",
  "version": "1.0.0",
  "description": "Redacts Personally Identifiable Information (PII) from text or JSON objects to ensure data privacy and compliance.",
  "capabilities": [
    "privacy",
    "dlp"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "input": {
        "type": "object",
        "description": "Text or JSON Object to redact"
      },
      "strategy": {
        "type": "string",
        "enum": [
          "mask",
          "remove"
        ],
        "default": "mask"
      },
      "rules": {
        "type": "array",
        "default": [
          "email",
          "credit_card"
        ],
        "description": "Regex or Predefined Types"
      }
    },
    "required": [
      "input"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "input": {
        "type": "object"
      },
      "strategy": {
        "type": "string"
      },
      "rules": {
        "type": "array"
      }
    },
    "required": [
      "input"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "object",
        "description": "Redacted content"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Redacted",
      "description": "Clean data",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Processing failed",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "sync",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard"
  ],
  "tags": [
    "pii",
    "compliance"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_veripass",
    "profile": {
      "name": "Veripass",
      "verified": true,
      "url": "https://me.veripass.com/veripass",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
No
Capabilities
privacydlp
Tags
piicompliance

Notes and limits

  • Only the listed patterns are redacted: names, addresses, national ids in other formats and 15-digit card numbers pass through unchanged.
  • Leaving through error does not fail the run: the engine follows the edges wired to error, and if there are none the branch simply ends.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs