Registry / security / ssn-formatter

ssn-formatter

JSON →
library1.0.0jsnpmunverified

A lightweight JavaScript library for parsing, formatting, and masking US Social Security Numbers. Current stable version is 1.0.0, released with no subsequent updates. It provides a simple API via `SSNFormatter.parse()` returning an object with area, group, and serial parts, and a `format()` method supporting customizable masks. Key differentiators include minimal dependencies and straightforward pattern-based parsing using characters A-I for SSN digits. However, it lacks TypeScript types, is not actively maintained, and has no built-in validation for invalid SSNs like 000 or 666 prefixes.

npm install ssn-formatter
INSTALL
IMPORT
SIG · SSN-FORMATTER
S
ssn-formatter
securityjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SSNFormatter
const SSNFormatter = require('ssn-formatter');
import { SSNFormatter } from 'ssn-formatter';
This package only provides a CommonJS export; ES module import will fail.

Shows parsing a SSN with a format pattern, accessing area/group/serial, and formatting with masking.

const SSNFormatter = require('ssn-formatter'); // Parse a formatted SSN let ssn = SSNFormatter.parse('123-44-4444', 'ABC-DE-FGHI'); console.log(ssn.value); // '123444444' console.log(ssn.area); // '123' console.log(ssn.group); // '44' console.log(ssn.serial); // '4444' // Format with masking let formatted = ssn.format('***-**-VVVV'); console.log(formatted); // '***-**-4444' // Parse without format (assumes digits only) let raw = SSNFormatter.parse('123444444'); console.log(raw.value); // '123444444'
Debug
Known issues
gotchaThe package does not validate SSNs (e.g., area 000, 666, or 900-999). It will parse any 9-digit combination.
fix
Implement your own validation logic before or after parsing.
affects: >=0.0.0
deprecatedThe package has not been updated; it lacks TypeScript definitions and modern ESM support.
fix
Consider migrating to a maintained alternative such as 'ssn-validator' if support is needed.
affects: >=1.0.0
breakingIf you use a pattern with fewer than 9 characters (e.g., 'C-DE-F'), partial SSNs are padded with asterisks, which may not be expected.
fix
Ensure the input string length matches the pattern or use the full 9-digit pattern.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: SSNFormatter.parse is not a function
Importing incorrectly using ES module import syntax.
fix
Use `const SSNFormatter = require('ssn-formatter');` instead.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
Resources
ssn-formatter — npm install ssn-formatter · libregistry