US SSN Number Regular Expression

A regular expression that accurately matches the valid SSN (Social Security Number) number.

/^(?!666|000|9\\d{2})\\d{3}-(?!00)\\d{2}-(?!0{4})\\d{4}$/

Where:

  • (?!666|000|9\\d{2})\\d{3} represents the first 3 digits should not start with 000, 666, or between 900 and 999.
  • (?!00)\\d{2} represents the next 2 digits should not start with 00 and it should be any from 01-99.
  • (?!0{4})\\d{4} represents the next 4 digits can’t 0000 and it should be any from 0001-9999.

SSN Number Examples:

  • 123-33-0002
  • 231-22-1234
  • 321-66-4321

See Also:

Regex Is Copied!