zipcodes.js
Free postal code validation for the web.
Validates against expected regex patterns of the country.
Looks up the code via a CDN for accurate validation and geographical data.
< script src ="https://cdn.jsdelivr.net/gh/zipcodes/zipcodes.js@1/zipcodes.min.js "> </ script >
getZipCode ( 'US' , '90210' , function ( result ) {
console . log ( result ) ;
} ) ;
Output:
{
"input" :{
"country" : "US" ,
"zip" : "90210"
} ,
"lookup" :{
"countryCode" : "US" ,
"postalCode" : "90210" ,
"placeName" : "Beverly Hills" ,
"adminName1" : "California" ,
"adminCode1" : "CA" ,
"adminName2" : "Los Angeles" ,
"adminCode2" : "037" ,
"adminName3" : "" ,
"adminCode3" : "" ,
"latitude" : "34.0901" ,
"longitude" : "-118.4065" ,
"accuracy" : "4"
} ,
"pattern" : / ^ \d { 5 } ( - \d { 4 } ) ? $ / ,
"validPattern" : true ,
"validLookup" : true ,
"valid" : true
}
Country codes should follow ISO 3166-1 alpha-2
Flag
Code
Country
Regex
Lookup
AD
Andorra
β
β
AE
United Arab Emirates
β
β
AF
Afghanistan
β
β
AG
Antigua and Barbuda
β
β
AI
Anguilla
β
β
AL
Albania
β
β
AM
Armenia
β
β
AO
Angola
β
β
AQ
Antarctica
β
β
AR
Argentina
β
β
AS
American Samoa
β
β
AT
Austria
β
β
AU
Australia
β
β
AW
Aruba
β
β
AX
sort
β
β
AZ
Azerbaijan
β
β
BA
Bosnia and Herzegovina
β
β
BB
Barbados
β
β
BD
Bangladesh
β
β
BE
Belgium
β
β
BF
Burkina Faso
β
β
BG
Bulgaria
β
β
BH
Bahrain
β
β
BI
Burundi
β
β
BJ
Benin
β
β
BL
Saint BarthΓ©lemy
β
β
BM
Bermuda
β
β
BN
Brunei
β
β
BO
Bolivia
β
β
BQ
Caribbean Netherlands
β
β
BR
Brazil
β
β
BS
The Bahamas
β
β
BT
Bhutan
β
β
BV
Bouvet Island
β
β
BW
Botswana
β
β
BY
Belarus
β
β
BZ
Belize
β
β
CA
Canada
β
β
CC
Cocos (Keeling) Islands
β
β
CD
Democratic Republic of the Congo
β
β
CF
Central African Republic
β
β
CG
Republic of the Congo
β
β
CH
Switzerland
β
β
CI
Cote d'Ivoire
β
β
CK
Cook Islands
β
β
CL
Chile
β
β
CM
Cameroon
β
β
CN
China
β
β
CO
Colombia
β
β
CR
Costa Rica
β
β
CU
Cuba
β
β
CV
Cabo Verde
β
β
CW
CuraΓ§ao
β
β
CX
Christmas Island
β
β
CY
Cyprus
β
β
CZ
Czechia
β
β
DE
Germany
β
β
DJ
Djibouti
β
β
DK
Denmark
β
β
DM
Dominica
β
β
DO
Dominican Republic
β
β
DZ
Algeria
β
β
EC
Ecuador
β
β
EE
Estonia
β
β
EG
Egypt
β
β
EH
Western Sahara
β
β
ER
Eritrea
β
β
ES
Spain
β
β
ET
Ethiopia
β
β
FI
Finland
β
β
FJ
Fiji
β
β
FK
Falkland Islands
β
β
FM
Federated States of Micronesia
β
β
FO
Faroe Islands
β
β
FR
France
β
β
GA
Gabon
β
β
GB
United Kingdom
β
β
GD
Grenada
β
β
GE
Georgia
β
β
GF
French Guiana
β
β
GG
Guernsey
β
β
GH
Ghana
β
β
GI
Gibraltar
β
β
GL
Greenland
β
β
GM
The Gambia
β
β
GN
Guinea
β
β
GP
Guadeloupe
β
β
GQ
Equatorial Guinea
β
β
GR
Greece
β
β
GS
South Georgia and the South Sandwich Islands
β
β
GT
Guatemala
β
β
GU
Guam
β
β
GW
Guinea-Bissau
β
β
GY
Guyana
β
β
HK
Hong Kong
β
β
HM
Heard Island and McDonald Islands
β
β
HN
Honduras
β
β
HR
Croatia
β
β
HT
Haiti
β
β
HU
Hungary
β
β
ID
Indonesia
β
β
IE
Republic of Ireland
β
β
IL
Israel
β
β
IM
Isle of Man
β
β
IN
India
β
β
IO
British Indian Ocean Territory
β
β
IQ
Iraq
β
β
IR
Iran
β
β
IS
Iceland (IC)
β
β
IT
Italy
β
β
JE
Jersey
β
β
JM
Jamaica
β
β
JO
Jordan
β
β
JP
Japan
β
β
KE
Kenya
β
β
KG
Kyrgyzstan
β
β
KH
Cambodia
β
β
KI
Kiribati
β
β
KM
Comoros
β
β
KN
Saint Kitts and Nevis
β
β
KP
North Korea
β
β
KR
South Korea
β
β
KW
Kuwait
β
β
KY
Cayman Islands
β
β
KZ
Kazakhstan
β
β
LA
Laos
β
β
LB
Lebanon
β
β
LC
Saint Lucia
β
β
LI
Liechtenstein
β
β
LK
Sri Lanka
β
β
LR
Liberia
β
β
LS
Lesotho
β
β
LT
Lithuania
β
β
LU
Luxembourg
β
β
LV
Latvia
β
β
LY
Libya
β
β
MA
Morocco
β
β
MC
Monaco
β
β
MD
Moldova
β
β
ME
Montenegro
β
β
MF
Collectivity of Saint Martin
β
β
MG
Madagascar
β
β
MH
Marshall Islands
β
β
MK
Republic of Macedonia
β
β
ML
Mali
β
β
MM
Myanmar
β
β
MN
Mongolia
β
β
MO
Macau
β
β
MP
Northern Mariana Islands
β
β
MQ
Martinique
β
β
MR
Mauritania
β
β
MS
Montserrat
β
β
MT
Malta
β
β
MU
Mauritius
β
β
MV
Maldives
β
β
MW
Malawi
β
β
MX
Mexico
β
β
MY
Malaysia
β
β
MZ
Mozambique
β
β
NA
Namibia
β
β
NC
New Caledonia
β
β
NE
Niger
β
β
NF
Norfolk Island
β
β
NG
Nigeria
β
β
NI
Nicaragua
β
β
NL
Netherlands
β
β
NO
Norway
β
β
NP
Nepal
β
β
NR
Nauru
β
β
NU
Niue
β
β
NZ
New Zealand
β
β
OM
Oman
β
β
PA
Panama
β
β
PE
Peru
β
β
PF
French Polynesia
β
β
PG
Papua New Guinea
β
β
PH
Philippines
β
β
PK
Pakistan
β
β
PL
Poland
β
β
PM
Saint Pierre and Miquelon
β
β
PN
Pitcairn Islands
β
β
PR
Puerto Rico
β
β
PS
State of Palestine
β
β
PT
Portugal
β
β
PW
Palau
β
β
PY
Paraguay
β
β
QA
Qatar
β
β
RE
RΓ©union
β
β
RO
Romania
β
β
RS
Serbia.
β
β
RU
Russia
β
β
RW
Rwanda
β
β
SA
Saudi Arabia
β
β
SB
Solomon Islands
β
β
SC
Seychelles
β
β
SD
Sudan
β
β
SE
Sweden
β
β
SG
Singapore
β
β
SH
Saint Helena, Ascension and Tristan da Cunha
β
β
SI
Slovenia
β
β
SJ
Svalbard and Jan Mayen
β
β
SK
Slovakia
β
β
SL
Sierra Leone
β
β
SM
San Marino
β
β
SN
Senegal
β
β
SO
Somalia
β
β
SR
Suriname
β
β
SS
South Sudan
β
β
ST
SΓ£o TomΓ© and PrΓncipe
β
β
SV
El Salvador
β
β
SX
Sint Maarten
β
β
SY
Syria
β
β
SZ
Swaziland
β
β
TC
Turks and Caicos Islands
β
β
TD
Chad
β
β
TF
French Southern and Antarctic Lands
β
β
TG
Togo
β
β
TH
Thailand
β
β
TJ
Tajikistan
β
β
TK
Tokelau
β
β
TL
East Timor
β
β
TM
Turkmenistan
β
β
TN
Tunisia
β
β
TO
Tonga
β
β
TR
Turkey
β
β
TT
Trinidad and Tobago
β
β
TV
Tuvalu
β
β
TW
Taiwan
β
β
TZ
Tanzania
β
β
UA
Ukraine
β
β
UG
Uganda
β
β
UM
United States Minor Outlying Islands
β
β
US
United States
β
β
UY
Uruguay
β
β
UZ
Uzbekistan
β
β
VA
Vatican City
β
β
VC
Saint Vincent and the Grenadines
β
β
VE
Venezuela
β
β
VG
British Virgin Islands
β
β
VI
United States Virgin Islands
β
β
VN
Vietnam
β
β
VU
Vanuatu
β
β
WF
Wallis and Futuna
β
β
WS
Samoa
β
β
YE
Yemen
β
β
YT
Mayotte
β
β
ZA
South Africa
β
β
ZM
Zambia
β
β
ZW
Zimbabwe
β
β