International Zip Code Validation: What’s the Ultimate Postal Code Regex?

GeoPostcodes-International zip code validation
Updated: September 1, 2026
Table of Contents

Key Takeaways:

  • Global postal code validation can’t use a single regex due to varying formats between countries
  • Country-specific regex patterns ensure proper validation by matching local postal standards
  • Implementation requires identifying the country first, then applying its specific regex
  • Combine regex with a global postal database to validate existing codes

Introduction

When developers search for the ultimate postal code regex, they often hope to find a single expression that covers every country’s postal code format. However, this task is challenging because postal codes differ in format, length, and structure. This tutorial will guide you through effectively implementing regex patterns for international zip code validation.

While regex can catch formatting issues, it cannot verify whether a postal code is real. A non-negotiable component of an international validator is a trustworthy, accurate data source.

Try Our ZIP Code Lookup Tool

Enter any ZIP code in the USA

Need International Coverage?

Get access to location data from 247 countries.

Check our PHP Street Address Validation guide if you’re also interested in validating addresses.

The Core Problem with a Global Postal Code Regex

There isn’t a singular regex that accurately validates postal codes globally. Because zip code formats vary across countries. This variety makes it impossible to encapsulate them in a single, precise regular expression. Attempting to do a single regex can lead to false positives, where invalid postal codes pass validation, or false negatives, where valid codes are rejected. Here is why:

  • Diverse Formats: Postal codes in different countries vary in formats—some use only numbers, others a combination of letters and numbers. For example, the US uses five digits (with an optional four-digit extension), while the UK combines letters and numbers.
  • Length Variations: Some postal codes are as short as three digits (Faroe Islands), while others can be as long as eight (Brazil).
  • Special Characters: In some countries, postal codes contain spaces, dashes, or other characters. For example, UK postal codes are often written with a space separating the first and second half (e.g., SW1A 1AA).
  • ZIP Codes often change: Have you ever wondered how often zip codes change? New postal codes can be added or removed periodically, further complicating the validation process if relying solely on static patterns.

Why Country-Specific Regex is the Way to Go

Each country’s postal system follows different standards, so country-specific postal code regexes based on each country’s system ensure correctness.

By applying the correct regular expression based on the country, you can ensure that:

  • Your system only accepts valid codes
  • You avoid false positives, where an incorrect postal code gets through
  • You reduce false negatives, where a valid postal code gets rejected

List of International Postal Codes Regex

The table below contains all countries’ correct postal code regexes and international zip code formats from the GeoPostcodes database.

💡 Download the full CSV file below with all countries’ zip code formats and regex.

ISOCountrySovereignZip FormatZip NameRegex
AFAfghanistanAF9999Postal code\d{4}
AXÅlandFI99999Postnummer\d{5}
ALAlbaniaAL9999Kodi Postar\d{4}
DZAlgeriaDZ99999Code postal\d{5}
ASAmerican SamoaUS96799ZIP code96799
ADAndorraADAD999Postal codeAD\d{3}
AOAngolaAO
AIAnguillaGBAI-2640PostcodeAI\-\d{4}
AGAntigua and BarbudaAG
ARArgentinaARA9999 AAACPA[A-Z]\d{4}\s[A-Z]{3}
AMArmeniaAM9999Փոստային ինդեքս\d{4}
AWArubaNL
AUAustraliaAU9999Postcode\d{4}
ATAustriaAT9999PLZ\d{4}
AZAzerbaijanAZAZ 9999Poçt indeksiAZ\s\d{4}
BSBahamasBS
BHBahrainBH[9]999Block\d{3,4}
BDBangladeshBD9999Postal code\d{4}
BBBarbadosBB99999Postal code\d{5}
BYBelarusBY299999Паштовы індэкс2\d{5}
BEBelgiumBE9999Code postal\d{4}
BZBelizeBZ
BJBeninBJ
BMBermudaGBAA 99Postcode[A-Z]{2}\s[\dA-Z]{2}
BTBhutanBT99999Postcode\d{5}
BOBoliviaBO
BABosnia and HerzegovinaBA99999Poštanski broj\d{5}
BWBotswanaBW
BVBouvet IslandNOPostnummer
BRBrazilBR99999-999CEP\d{5}\-\d{3}
IOBritish Indian Ocean TerritoryGBBBND 1ZZPostcodeBBND 1ZZ
VGBritish Virgin IslandsGBVG9999PostcodeVG\d{4}
BNBrunei DarussalamBNAA9999Postal code[A-Z]{2}\d{4}
BGBulgariaBG9999Пощенски код\d{4}
BFBurkina FasoBF99999\d{5}
BIBurundiBI
KHCambodiaKH999999Postal code\d{6}
CMCameroonCM
CACanadaCAA9A 9A9Postal code[A-Z]\d[A-Z]\s\d[A-Z]\d
CVCape VerdeCV9999-999Postal code\d{4}-\d{3}
KYCayman IslandsGBKY9-9999PostcodeKY\d\-\d{4}
CFCentral African RepublicCF
TDChadTD
CLChileCL9999999Código postal\d{7}
CNChinaCN999999邮政编码\d{6}
CXChristmas IslandAU6798Postcode6798
CCCocos (Keeling) IslandsAU6799Postcode6799
COColombiaCO999999Código postal\d{6}
KMComorosKM
CGCongo-BrazzavilleCG
CDCongo, Democratic RepublicCD9999999Code postal\d{7}
CKCook IslandsNZ
CRCosta RicaCR99999Código postal\d{5}
CICôte d'IvoireCI
HRCroatiaHR99999Postal code\d{5}
CUCubaCU99999Código postal\d{5}
CWCuraçaoNL
CYCyprusCY9999Postal code\d{4}
CZCzechiaCZ999 99PSČ\d{3}\s\d{2}
DKDenmarkDK9999Postnummer\d{4}
DJDjiboutiDJ
DMDominicaDM
DODominican RepublicDO99999Código postal\d{5}
ECEcuadorEC999999Código postal\d{6}
EGEgyptEG99999الرمز البريدى\d{5}
SVEl SalvadorSV99999Código postal\d{5}
GQEquatorial GuineaGQ
EREritreaER
EEEstoniaEE99999Postiindeks\d{5}
SZEswatiniSZA999Postal code[A-Z]\d{3}
ETEthiopiaET
FKFalkland IslandsGBFIQQ 1ZZPostcodeFIQQ 1ZZ
FOFaroe IslandsDK999Postnummer\d{3}
FJFijiFJ
FIFinlandFI99999Postinumero\d{5}
FRFranceFR99999Code postal\d{5}
GFFrench GuianaFR99999Code postal\d{5}
PFFrench PolynesiaFR99999Code postal\d{5}
TFFrench Southern TerritoriesFR
GAGabonGA
GMGambiaGM
GEGeorgiaGE9999საფოსტო ინდექსის\d{4}
DEGermanyDE99999PLZ\d{5}
GHGhanaGHAA-99999-9999Postcode[A-Z][A-Z0-9]\-\d{5}\-\d{4}
GIGibraltarGBGX11 1AAPostcodeGX11 1AA
GRGreeceGR999 99ΤΚ\d{3}\s\d{2}
GLGreenlandDK9999Postnummer\d{4}
GDGrenadaGD
GPGuadeloupeFR99999Code postal\d{5}
GUGuamUS99999ZIP code\d{5}
GTGuatemalaGT99999Código postal\d{5}
GGGuernseyGBGY99 9AAPostcodeGY\d{1,2}\s\d[A-Z]{2}
GNGuineaGN
GWGuinea-BissauGW
GYGuyanaGY
HTHaitiHT9999Code postal\d{4}
HMHeard and McDonald IslandsAU7151Postcode7151
HNHondurasHN
HKHong KongCN
HUHungaryHU9999Irányítószám\d{4}
ISIcelandIS999Póstnúmer\d{3}
INIndiaIN999999PIN code\d{6}
IDIndonesiaID99999Kodhe pos\d{5}
IRIranIR9999999999Postal code\d{10}
IQIraqIQ99999Postal code\d{5}
IEIrelandIEA99 AAAAEircode[A-Z](\d{2}|6W)\s[A-Z]{4}
IMIsle of ManGBIM99 9AAPostcodeIM\d{1,2}\s\d[A-Z]{2}
ILIsraelIL99999 99Postal code\d{5}\s\d{2}
ITItalyIT99999CAP\d{5}
JMJamaicaJMPostal code
JPJapanJP999-9999郵便番号\d{3}\-\d{4}
JEJerseyGBJE9 9AAPostcodeJE\d\s\d[A-Z]{2}
JOJordanJO99999Postal code\d{5}
KZKazakhstanKZA99A9A9Пошта индексі[A-Z]\d{2}[A-Z]\d[A-Z]\d
KEKenyaKE99999Postal code\d{5}
KIKiribatiKIKI0999PostcodeKI0\d{3}
XKKosovoXK99999Zip codes
KWKuwaitKW99999Postal code\d{5}
KGKyrgyzstanKG999999Postal code\d{6}
LALaosLA99999Postal code\d{5}
LVLatviaLV9999Pasta indekss\d{4}
LBLebanonLB9999 9999Postal code\d{4}\s\d{4}
LSLesothoLS999Postal code\d{3}
LRLiberiaLR9999Postal code\d{4}
LYLibyaLY99999Postal code\d{5}
LILiechtensteinLI9999PLZ\d{4}
LTLithuaniaLT99999Pašto kodas\d{5}
LULuxembourgLU9999Code postal\d{4}
MOMacauCN
MGMadagascarMG999Code postal\d{3}
MWMalawiMW999999Postcode\d{6}
MYMalaysiaMY99999Postal code\d{5}
MVMaldivesMV99999Postcode\d{5}
MLMaliML99999Code postal\d{5}
MTMaltaMTAAA 9999Postal code[A-Z]{2,3}\s\d{2,4}
MHMarshall IslandsUS99999ZIP code\d{5}
MQMartiniqueFR99999Code postal\d{5}
MRMauritaniaMR
MUMauritiusMU99999Post code[\dR]\d{3,4}
YTMayotteFR99999Code postal\d{5}
MXMexicoMX99999Código postal\d{5}
FMMicronesiaUS99999ZIP code\d{5}
UMMinor Outlying IslandsUS96898ZIP Code\d{5}
MDMoldovaMD9999Coduri poștale\d{4}
MCMonacoMC98000Code postal9800\d
MNMongoliaMN99999Postal code\d{5}
MEMontenegroME99999Postal code\d{5}
MSMontserratGBMSR9999PostcodeMSR\d{4}
MAMoroccoMA99999Code postal\d{5}
MZMozambiqueMZ9999Postal code\d{4}
MMMyanmarMM9999999Postal code\d{7}
NANamibiaNA99999Post Code\d{5}
NRNauruNRNRU 68PostcodeNRU 68
NPNepalNP99999Postal code\d{5}
NLNetherlandsNL9999 AAPostcode\d{4}\s[A-Z]{2}
NCNew CaledoniaFR99999Code postal\d{5}
NZNew ZealandNZ9999Postal code\d{4}
NINicaraguaNI99999Código postal\d{5}
NENigerNE9999Code postal\d{4}
NGNigeriaNG999999Postal code\d{6}
NUNiueNZ9974Postal code9974
NFNorfolk IslandAU2899Postcode28\d{2}
KPNorth KoreaKP
MPNorthern Mariana IslandsUS99999ZIP code\d{5}
NONorwayNO9999Postnummer\d{4}
OMOmanOM999Postal code\d{3}
PKPakistanPK99999Postal code\d{5}
PWPalauUS96999ZIP code969\d{2}
PSPalestinePSP999 9999PostcodeP\d{3}\s\d{4}
PAPanamaPA
PGPapua New GuineaPG999Postal code\d{3}
PYParaguayPY999999Código postal\d{6}
PEPeruPE99999Código postal\d{5}
PHPhilippinesPH9999Postal code\d{4}
PNPitcairn IslandsGBPCRN 1ZZPostcodePCRN 1ZZ
PLPolandPL99-999Kod pocztowy\d{2}\-\d{3}
PTPortugalPT9999-999Código postal\d{4}\-\d{3}
PRPuerto RicoUS99999ZIP code\d{5}
QAQatarQA
MKRepublic of North MacedoniaMK9999Postal code\d{4}
RERéunionFR99999Code postal\d{5}
RORomaniaRO999999Cod poștal\d{6}
RURussiaRU999999Почтовый индекс\d{6}
RWRwandaRW
BLSaint BarthélemyFR99999Code postal\d{5}
SHSaint Helena, Ascension and Tristan da CunhaGBAAAA 1ZZPostcode[A-Z]{4}\s1ZZ
KNSaint Kitts and NevisKN
LCSaint LuciaLCLC99 999PostcodeLC\d{2}\s\d{3}
MFSaint MartinFR99999Code postal\d{5}
PMSaint Pierre and MiquelonFR99999Code postal\d{5}
VCSaint Vincent and the GrenadinesVCVC9999Postal codeVC\d{4}
WSSamoaWSWS9999PostcodeWS\d{4}
SMSan MarinoSM99999CPI\d{5}
STSão Tomé and PríncipeST
SASaudi ArabiaSA99999Postal code\d{5}
SNSenegalSN99999Code postal\d{5}
RSSerbiaRS99999Poštanski broj\d{5}
SCSeychellesSC
SLSierra LeoneSL
SGSingaporeSG999999Postal code\d{6}
SXSint MaartenNL
SKSlovakiaSK999 99PSČ\d{3}\s\d{2}
SISloveniaSI9999Poštna številka\d{4}
SBSolomon IslandsSB
SOSomaliaSO
ZASouth AfricaZA9999Postal code\d{4}
GSSouth Georgia and SandwichGBSIQQ 1ZZPostcodeSIQQ 1ZZ
KRSouth KoreaKR99999우편번호\d{5}
SSSouth SudanSS
ESSpainES99999Código postal\d{5}
LKSri LankaLK99999Postal code\d{5}
SDSudanSD
SRSurinameSR
SJSvalbard and Jan MayenNO9999Postnummer\d{4}
SESwedenSE999 99Postnummer\d{3}\s\d{2}
CHSwitzerlandCH9999NPA\d{4}
SYSyriaSY
TWTaiwanCN999999Postal code\d{6}
TJTajikistanTJ999999Postal code\d{6}
TZTanzaniaTZ99999Postal codes\d{5}
THThailandTH99999Postal code\d{5}
TLTimor-LesteTL
TGTogoTG
TKTokelauNZ
TOTongaTO
TTTrinidad and TobagoTT999999Postal code\d{6}
TNTunisiaTN9999Code postal\d{4}
TRTürkiyeTR99999Posta kodu\d{5}
TMTurkmenistanTM999999Postal code\d{6}
TCTurks and Caicos IslandsGBTKCA 1ZZPostcodeTKCA 1ZZ
TVTuvaluTV
VIU.S. Virgin IslandsUS99999ZIP code\d{5}
UGUgandaUG99999Postcodes
UAUkraineUA99999Поштовий індекс\d{5}
AEUnited Arab EmiratesAE
GBUnited KingdomGBAA9 9AAPostcode[A-Z]{1,2}[0-9][A-Z0-9]?\s[0-9][A-Z]{2}
USUnited StatesUS99999ZIP code\d{5}
UYUruguayUY99999Código postal\d{5}
UZUzbekistanUZ999999Postcode\d{6}
VUVanuatuVU
VAVaticanVA00120CAP120
VEVenezuelaVE9999Código postal\d{4}
VNVietnamVN99999Mã bưu chính\d{5}
WFWallis and FutunaFR99999Code postal\d{5}
YEYemenYE
ZMZambiaZM
ZWZimbabweZW

💡 Download the CSV file with a full table of all countries’ zip code formats and regex.

How to Implement the Regex System

  1. Identify the country: Before applying any regex, determine the user’s country (e.g., a country dropdown).
  2. Apply the corresponding regex: Once the country is known, use the appropriate regular expression to validate the postal code. For example:
import re

def validate_postal_code(postal_code, country_code):
    patterns = {
        'US': r'd{5}',
        'CA': r'[A-Z]d[A-Z]sd[A-Z]d',
        'UK': r'[A-Z]{1,2}[0-9][A-Z0-9]?s[0-9][A-Z]{2}',
        # Add more country-specific patterns here
    }

    pattern = patterns.get(country_code.upper())
    if pattern:
        return re.match(pattern, postal_code)
    else:
        # Fallback for unrecognized formats
        return re.match(r'^[A-Za-z0-9- ]{2,10}$', postal_code)

# Example usage
print(validate_postal_code('90210', 'US'))  # True
print(validate_postal_code('SW1A 1AA', 'UK'))  # True
print(validate_postal_code('G2B 0T3', 'CA'))  # True

Fallback for Unrecognized Formats: If your application serves users globally and specific regex for some countries isn’t feasible, allow a fallback regex that captures common postal code structures, such as:

^[A-Za-z0-9- ]{2,10}$

Conclusion

This blog covered why a one-size-fits-all postal code regex doesn’t work, how country-specific regex ensures better accuracy, and why pairing regex with a reliable data source is critical for complete validation. We also provided accurate regex patterns based on international postal code formats and explained how to implement them.

While country-specific regex catches formatting issues, it doesn’t guarantee that the postal code is valid. The key to effective validation is coupling regex with a reliable, global postal code database that ensures the codes you’re validating exist.

At GeoPostcodes, we’ve compiled our worldwide zip code database for over 15 years, providing businesses with the most accurate data.

Whether you’re handling logistics, e-commerce, or CRM, our database will help you precisely validate postal codes, ensuring smooth operations and happy customers. Ready to enhance your postal code validation process? Browse our datasets and download a free sample to see the difference.

FAQ

What is the ultimate postal code and zip regex?

Creating a regex pattern that matches all postal and ZIP codes globally is quite complex due to the varying formats used by different countries.

Check out our international zip code validation guide to learn how to resolve this issue.

How to validate the ZIP code?

Check out our guide on How to Use Python to Validate Zip Codes for a step-by-step explanation.

Is the International postal code the same as the ZIP code?

In general, zip codes refer to postal codes used in the United States, while postal codes are a broader term used internationally.

Different countries have unique postal code systems, such as Canadian postal codes, which use a combination of letters and numbers.

Check out our article on Zip Code vs. Postcode to learn more.

What is the format of a ZIP code in Europe?

Most countries in Europe use a four- or five-digit numeric code.

Notable exceptions include the UK and the Netherlands, which use alphanumeric postcodes of six to eight characters.

Check out the GeoPostcodes Database of Europe Zip Codes here.

How do I validate international zip codes?

Validating international zip codes requires checking them against country-specific formats, as postal codes vary by country.

This can be achieved by using postal code regex patterns for each country.

How can I validate addresses on my e-commerce platform?

For accurately validating addresses for your e-commerce platform, use services that validate zip codes and other address details, like country code, street address, and postal code, to confirm the information is correct and deliverable.

GeoPostcodes offers detailed postal code data, including zip codes, country codes, and address structures, which can be integrated into your system to confirm the accuracy of address information and enhance deliverability.

How does postal code regex work for address validation?

Postal code regex (regular expressions) define the valid structure of a postal code for each country.

This method helps verify whether the entered postal code adheres to the correct format for that specific region.

What is the best way to validate postal addresses?

To ensure postal address accuracy, it is essential to use an address validation tool that relies on accurate and up-to-date data, like GeoPostcodes, which checks the completeness and correctness of the address, including street names, city, postal codes, and country.

Where can I find international postal code data?

GeoPostcodes maintains a comprehensive world postal code database covering postal codes from countries globally.

How do I validate zip codes from different countries?

Use GeoPostcodes’ verify international address service, which validates postal codes as part of complete address verification.

Can I validate zip codes in bulk?

Yes, GeoPostcodes’ batch address check service can validate thousands of postal codes from any country efficiently.

Related posts

GeoPostcodes inverted logo