Validationflags: g
US Social Security Number
Match US Social Security Numbers in the canonical XXX-XX-XXXX format.
Try it in RegexProPattern
regexJavaScript
/\b\d{3}-\d{2}-\d{4}\b/gRaw source: \b\d{3}-\d{2}-\d{4}\b
How it works
Three digits, hyphen, two digits, hyphen, four digits. Word boundaries prevent false matches inside longer digit runs. Note: this pattern does not validate SSN issuance rules.
Examples
Input
123-45-6789Matches
123-45-6789
Input
SSN: 987-65-4321 on fileMatches
987-65-4321
Input
123456789No match
—Common use cases
- PII detection in logs or documents
- Data loss prevention (DLP) scanning
- Form field validation in US apps
- Redaction pipelines for compliance