# SSN Format Validation: Numbers That Can Never Be Real

- Canonical: https://schematax.com/blog/ssn-format-validation
- Author: Schema Tax (https://schematax.com)
- Published: 2026-05-19T10:24:41.000Z
- Updated: 2026-05-19T10:24:41.000Z

SSN format validation checks that a Social Security number has nine digits in the 3-2-4 layout and that none of its three parts uses a value the Social Security Administration treats as invalid: area 000, 666 or 900 to 999, group 00, or serial 0000. A number that passes could exist. One that fails cannot.

## The AAA-GG-SSSS parts of a Social Security number

A Social Security number (SSN) is the nine-digit number the Social Security Administration (SSA) issues to people. The SSA's operations manual, [POMS RM 10201.030 on the structure of the SSN](https://secure.ssa.gov/poms.nsf/lnx/0110201030), says the SSN "consists of nine digits, separated into three groups by hyphens."

The same section names the three groups. The first three digits are the area number, the middle two are the group number, and the last four are the serial number. Written out, that is AAA-GG-SSSS, so a hyphen follows the third digit and another follows the fifth.

Tax forms use that layout too. The [IRS General Instructions for Certain Information Returns](https://www.irs.gov/instructions/i1099gi) say SSNs, ITINs and ATINs have "nine digits separated by two hyphens (000-00-0000)." An employer identification number uses one hyphen after the second digit instead, which the [EIN vs SSN vs ITIN format comparison](/blog/ein-vs-ssn-vs-itin-format) uses to tell the two apart.

Strip the hyphens before you store or compare an SSN, and store the result as text. Treating the value as a number drops a leading zero, and SSNs can start with 0.

## Which SSN area numbers are never issued?

The SSN area number is the first three digits. The SSA's manual section on [verifying an SSN, POMS RM 10201.035](https://secure.ssa.gov/poms.nsf/lnx/0110201035), treats an SSN as invalid when its area number is 000, 666, or in the 900 series. Those three rules are the core of any SSN format validation.

That gives three tests on the first three digits:

- Area 000: never valid.
- Area 666: never valid.
- Area 900 to 999: never valid as an SSN.

The 900 series needs care. A number starting with 9 is not an SSN, but it may be a valid IRS number. ITINs and ATINs are both issued by the IRS in the same 3-2-4 layout and both begin with 9. A validator that only knows SSN rules will reject them. The [ITIN middle-digit ranges](/blog/valid-itin#the-itin-middle-digit-ranges) show which numbers starting with 9 are ITINs.

## SSN group and serial numbers that fail validation

The SSN group number is the middle two digits and the serial number is the last four. POMS RM 10201.035 treats an SSN as invalid when its group number is 00 or its serial number is 0000. Every other group from 01 to 99 and every serial from 0001 to 9999 passes a format check.

Together with the area rules, that makes five checks in all. The regex below runs them on a string with or without hyphens:

```
^(?!000|666|9[0-9]{2})[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4}$
```

Each `(?!...)` is a negative lookahead: it rejects the position if the next characters match a forbidden value. Here are example values and the rule each one tests. The passing row uses N for any digit so that no real SSN appears on this page.

| Example value (fictional) | Result | Rule it tests |
| --- | --- | --- |
| 000-12-3456 | Fail | Area 000 |
| 666-12-3456 | Fail | Area 666 |
| 987-00-1234 | Fail | Area in the 900 series (also group 00) |
| 123-00-4567 | Fail | Group 00 |
| 123-45-0000 | Fail | Serial 0000 |
| 07-1234567 | Fail | EIN layout, one hyphen |
| 1NN-NN-NNNN with no zero block | Pass | Nine digits, no forbidden part |

Mixed hyphen use, such as one hyphen out of two, also passes this regex because each hyphen is optional. If your input should always be printed layout, make both hyphens required.

## How did SSN randomization in 2011 change format validation?

SSN randomization changed how the SSA assigns new numbers from June 25, 2011. The SSA manual section on [SSN assignment, POMS RM 10201.050](https://secure.ssa.gov/poms.nsf/lnx/0110201050), says: "Beginning June 25, 2011, we assign all SSNs randomly." It also says the SSA no longer allocates area numbers to specific states.

Before that date, POMS RM 10201.030 explains, the area number reflected the state, derived from the ZIP code in the mailing address on the application, and group numbers were issued in a set order. It then says that "Beginning June 25, 2011 forward, this structure is no longer of any significance."

For format validation, the effect is simple. Old checks that tied an area number to a state, or that rejected a group number not yet issued in that area, now reject real numbers. After randomization, the only reliable format rules are the five area, group and serial rules. Everything else about the digits is assignment history, not validity.

## SSN format validation mistakes: rejecting real numbers

SSN format validation mistakes that reject real numbers are worse than mistakes that accept bad ones, because they block a real person. Three habits cause most of them: using pre-2011 range tables, treating every number that starts with 9 as a bad SSN, and saving the number in a numeric field.

**Outdated range tables.** A rule that says a given area was only used by one state, or that a group is too high for its area, describes the system before randomization. Newer numbers break both assumptions. Remove those rules and keep the five that still hold.

**Treating ITINs as invalid SSNs.** A 1099 recipient TIN starting with 9 fails SSN rules but may be a correct ITIN, so route it to ITIN rules before you flag it. The post on [ITIN validation mistakes](/blog/valid-itin#itin-validation-mistakes-rejecting-a-9-as-an-invalid-ssn) covers which forms allow an ITIN and why the W-2 does not.

**Numeric storage.** An SSN starting with 0 loses that digit in a numeric column and fails the length test afterward. Fix the import, not the validator.

Format validation also ends where privacy begins. Once a number passes, most workflows only need the last four digits, and the post on [masking an SSN to the last four digits](/blog/ssn-masking-in-documents#masking-an-ssn-to-the-last-four-digits) covers that step. Schema Tax tests each SSN it reads against its pattern and then [masks it to the last four digits before storage](/#security). For lenders and others checking SSNs during underwriting, the [income verification guides](/blog/category/income-verification) cover the forms involved.
