EvvyTools.com EvvyTools.com
Home About Home & Real Estate Health & Fitness Freelance & Business Everyday Life Math Writing & Content Dev & Tech Data Lists Subscribe Contact
Sign In Create Account

Postal Code Formats by Country — Regex Patterns | EvvyTools

Postal code format, regex pattern, and example for every country

205 rows 4 columns

A reference dataset covering postal code formats for every country that uses them. Each row includes the format description, a regex pattern for server-side or client-side validation, and a real example code. Stop hard-coding postal validation rules country by country — download the complete set and drive your validation logic from data.

Pro tip: Not every country uses postal codes. This dataset only includes the ~160 countries that do. If a country is missing, it means they do not have a postal code system.

Select which columns to include in your download.

· ·

About the Postal Code Formats Dataset

This dataset provides postal code metadata for approximately 160 countries and territories that operate postal code systems. Each entry includes the country name, a human-readable format description, a regular expression pattern suitable for validation, and a valid example postal code. The formats range from simple numeric codes (like the five-digit US ZIP code) to complex alphanumeric patterns (like the UK postcode format). The regex patterns are provided without delimiters so you can use them directly in JavaScript, PHP, Python, or any language that supports standard regular expressions.

Common Use Cases

  • Address form validation: Load the regex patterns into your checkout or registration form to validate postal codes in real time based on the selected country, reducing invalid submissions and shipping errors.
  • Data cleaning: Run existing address datasets through the regex patterns to flag records with invalid or malformed postal codes before importing them into your CRM or shipping system.
  • Internationalization libraries: Use this dataset as the backing data for address validation libraries that need to support multiple countries without hard-coding each format.
  • API input validation: Validate postal code fields on your API endpoints server-side by looking up the appropriate regex for the request's country parameter.

Column Reference

  • country — The common English name of the country.
  • postal_format — A human-readable description of the postal code format (e.g. "NNNNN" for five-digit numeric, "ANA NAN" for Canadian alphanumeric).
  • regex_pattern — A regular expression pattern body (no delimiters) that validates postal codes for this country. Anchor with ^ and $ in your implementation.
  • example — A valid example postal code demonstrating the format.

Working with the Regex Patterns

The regex patterns in this dataset are provided as pattern bodies without surrounding delimiters. To use them in JavaScript, wrap them in a RegExp constructor: new RegExp('^' + pattern + '$'). In PHP, use preg_match with delimiters: preg_match('/^' . $pattern . '$/', $input). Most patterns use standard character classes (digits, letters) and quantifiers that work identically across regex engines. A few countries have complex formats with optional components — always test with the provided example value first.

Countries Without Postal Codes

Around 80 countries do not use postal code systems, including many island nations, some African countries, and a few others like Ireland (which only recently adopted Eircode). If your application needs to handle these countries, simply skip postal code validation when the country is not found in this dataset. This approach is more reliable than maintaining a separate list of countries to exclude.

Link copied to clipboard!

Upgrade Your Experience

Go ad-free across all tools and data lists. Subscribers also get saved history, SQL downloads, and early access to new tools.

Subscribe