# splatch

> A log/text sanitizer and masker

Latest version **1.0.18** (published 2026-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install splatch
pnpm add splatch
yarn add splatch
bun add splatch
```

Provides the command `splatch`.

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.18 |
| Published | 2026-06-28 |
| First published | 2024-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 44 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Timi Aiyemo |
| Maintainers | cozzbie |
| Keywords | mask, sanitize, node.js, npm, package, mask, data, datamask, maskdata, hide, protect, email, card, phone, uuid, string, sensitive, jwt, token |

## Links

- npm: https://www.npmjs.com/package/splatch
- Repository: https://github.com/cozzbie/splatch
- Homepage: https://github.com/cozzbie/splatch#readme
- Issues: https://github.com/cozzbie/splatch/issues
- npm.io page: https://npm.io/package/splatch

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.18 (latest) — 2026-06-28
- 1.0.17 — 2024-03-22
- 1.0.16 — 2024-03-22
- 1.0.15 — 2024-03-21
- 1.0.14 — 2024-03-21
- 1.0.10 — 2024-03-21
- 1.0.9 — 2024-03-17
- 1.0.8 — 2024-03-17
- 1.0.7 — 2024-03-17
- 1.0.6 — 2024-03-17

## README

## Splatch

Flexible Log sanitization/masking.

The library comes from the position of _what you want show_ as opposed to _what you do not want to show_ and what this means is that by default...everything is hidden (some exceptions exist like for emails where the default shows some entries conditionally).

### Features

You can pretty much mask anything but the focus here is on objects with fields to be masked
- Cards
- Emails
- Tokens
etc

### Install

- `yarn add --exact splatch`
- `npm i --save-exact --save splatch`


### How to use

Without custom email configurations and using the defaults

```javascript
import { splatch } from 'splatch';

const entry = {
    name: 'Jane Doe',
    email: 'jane@doe.com',
    business: {
        businessEmail: 'biz@izzy.com'
    }
};
const configs = {
    email: {
        fields: [/email/]
    }
};

const result = splatch({ entry, configs });

// {
//  name: 'Jane Doe',
//  email: 'j**e@**e.com',
//  business: {
//      businessEmail: '***@i**y.com'
//  }
// }
```

With custom email configuration that you can specify.

```javascript
import { splatch } from 'splatch';

const entry = {
    name: 'Jane Doe',
    email: 'jane@doe.com',
    business: {
        businessEmail: 'biz@izzy.com'
    }
};
const configs = {
    email: {
        fields: [/email/],
        config: {
            local: {
                start: 2
            }
        }
    }
};

const result = splatch({ entry, configs });

// {
//  name: 'Jane Doe',
//  email: 'ja*e@**e.com',
//  business: {
//      businessEmail: 'bi*@i**y.com'
//  }
// }
```

### Configuration Default

|        | Description                                                                | Email/Text | Card/Token/Generic | Phone |
|--------|----------------------------------------------------------------------------|------------|--------------------|-------|
| mask   | The symbol to be used with splatch/mask                                     | *          | *                  | *     |
| start  | Where to start the splatch/mask from                                        | 1          | 0                  | 4     |
| end    | Where to end the splatch/mask.                                              | 1          | 0                  | 0     |
| gutter | Total number of items to show between splatches.  Typically used with skip  | 0          | 0                  | 0     |
| skip   | Total number of items to splatch between gutters.                           | 0          | 0                  | 0     |


### Style Target Configurations

Currently 3 special types are exposed. Every other type can be expressed via providing custom configurations for the `token` type.

- Email

```javascript
const configs = {
    email: {
        fields: [/email/, 'anotherEmailField'],
        config: {
            local: {
                start: 2, // where you would want the mask to start from
                end: 1, // where you would want the mask to end
                mask: '*' // masking symbol to use
            },
            domain: {
                start: 2, // where you would want the mask to start from
                end: 1, // where you would want the mask to end
                mask: '$' // masking symbol to use
            },
            tld: {
                start: 2, // where you would want the mask to start from
                end: 1, // where you would want the mask to end
                mask: '^' // masking symbol to use
            }
        }
    }
};
```

- Cards/Tokens

```javascript
const configs = {
    card: {
        fields: [/credit/, 'debit'],
        config: {
            sections: [
                {
                    index: 0, // Select how you want a section of the card to be masked
                    config: {
                        start: 4 // where you would want the mask to start from
                    }
                },
                {
                    index: 3,
                    config: { start: 4 }
                }
            ]
        }
    }
};
```

- Phone Numbers

```javascript
const configs = {
    phone: {
        fields: [/phone/, 'phoneNumber'],
        config: {
            start: 4, // where you would want the mask to start from. Default is 4
            end: 0, // where you would want the mask to end
            mask: '*' // masking symbol to use
        }
    }
};
```

### Report Bugs

Well, #$%$ happens, please report here https://github.com/cozzbie/splatch/issues


### License

[MIT © Timi Aiyemo](https://cozzbie.mit-license.org/)

---
_Source: https://npm.io/package/splatch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
