Validate postal codes for different countries
Postal codes (also known as ZIP codes in the United States, postcodes in the United Kingdom, and postal codes in Canada) are alphanumeric codes used by postal services to identify geographic regions for mail delivery. These codes help postal services efficiently sort and deliver mail by dividing countries into smaller geographic areas. Different countries use different formats, lengths, and conventions for their postal code systems, making validation an important step in address verification and data quality management.
ZIP (Zone Improvement Plan) codes were introduced by the United States Postal Service (USPS) in 1963:
| First Digit | Region |
|---|---|
| 0 | Connecticut, Massachusetts, Maine, New Hampshire, New Jersey, Rhode Island, Vermont |
| 1 | Delaware, New York, Pennsylvania |
| 2 | District of Columbia, Maryland, North Carolina, South Carolina, Virginia, West Virginia |
| 3 | Alabama, Florida, Georgia, Mississippi, Tennessee |
| 4 | Indiana, Kentucky, Michigan, Ohio |
| 5 | Iowa, Minnesota, Montana, North Dakota, South Dakota, Wisconsin |
| 6 | Illinois, Kansas, Missouri, Nebraska |
| 7 | Arkansas, Louisiana, Oklahoma, Texas |
| 8 | Arizona, Colorado, Idaho, New Mexico, Nevada, Utah, Wyoming |
| 9 | Alaska, California, Hawaii, Oregon, Washington |
UK postcodes consist of two parts separated by a space:
| Format | Example | Location |
|---|---|---|
| AA9A 9AA | SW1A 1AA | Buckingham Palace, London |
| A9A 9AA | W1A 0AX | BBC Broadcasting House, London |
| A9 9AA | M1 1AE | Manchester city center |
| A99 9AA | B33 8TH | Birmingham |
| AA9 9AA | CR2 6XH | Croydon, South London |
| AA99 9AA | DN55 1PT | Doncaster |
Canada Post uses a six-character alphanumeric format:
| First Letter | Province/Territory |
|---|---|
| A | Newfoundland and Labrador |
| B | Nova Scotia |
| C | Prince Edward Island |
| E | New Brunswick |
| G, H, J | Quebec |
| K, L, M, N, P | Ontario |
| R | Manitoba |
| S | Saskatchewan |
| T | Alberta |
| V | British Columbia |
| X | Northwest Territories, Nunavut |
| Y | Yukon |
| Country | Format | Example |
|---|---|---|
| United States | 99999 or 99999-9999 | 90210, 10001-5432 |
| United Kingdom | AA9A 9AA (varies) | SW1A 1AA |
| Canada | A9A 9A9 | K1A 0B1 |
| Germany | 99999 | 10117 |
| France | 99999 | 75001 |
| Australia | 9999 | 2000 |
| Japan | 999-9999 | 100-0001 |
| Netherlands | 9999 AA | 1012 JS |
| Country | Valid Test Codes |
|---|---|
| United States | 12345, 90210, 10001-5432 |
| United Kingdom | SW1A 1AA, W1A 0AX, M1 1AE |
| Canada | K1A 0B1, M5H 2N2, V6B 4Y8 |
Many services offer postal code-based address autocomplete: