Postcodes

    Postcode Validation: Key Concepts

    Validating a postcode can mean checking its format, its existence or its match with the address. Learn the three levels and their limits.

    Updated 14 October 2026 · 2 min read

    Validating a postcode is not one task but three, and mixing them up is a frequent source of bugs. Each level gives a different guarantee.

    Level 1: format validation

    This checks that the value has the right shape for the country: the correct length, character types and separators. It is usually done with a pattern. It is quick and can run in the browser, but it only tells you the code could be a postcode, not that it is one.

    Examples of what format checks catch: letters in a digits-only system, too many characters, or the wrong country style. See postcode structure explained for how formats are built.

    Level 2: existence validation

    This checks that the code is actually in use, by comparing it with a list of known postcodes. It catches typos that happen to look valid. It needs reference data, which must be kept current, as discussed in how postcode systems are maintained. Without updates, new codes will be wrongly rejected.

    Level 3: address match validation

    This checks that the postcode fits the street and town entered. It is the strongest check and the hardest, because it requires address-level data. It is usually done by a specialist service or by the postal operator's own tools.

    Choosing the level

    For most forms, format validation plus a friendly warning is enough. Only block the user when you are certain of the rule. A wrongly rejected customer is a lost sale, while a mistyped code that passes may be caught later by the carrier. See also postcode formats in online forms.

    Normalisation before validation

    Trim spaces and standardise case first, and decide how to handle optional separators; see spaces and hyphens in postcodes.

    Validating location, not just the code

    If you need to know a point on a map, a postcode will not provide it. UPCS provides a separate lookup for exact-location codes, which return coordinates for a code. It does not validate postal addresses or postcodes, and it is not an address validation product.

    Frequently asked questions

    Is a regular expression enough to validate a postcode?

    It checks only the format. A code can match the pattern and still not exist or not match the street.

    Why would a valid postcode be rejected?

    The validation rule may be too strict, written for another country, or based on outdated data.