Postcodes

    Leading Zeros in Postcodes

    Postcodes that start with zero lose it when stored as numbers. Learn why this happens in spreadsheets and databases and how to prevent it.

    Updated 14 October 2026 · 2 min read

    A postcode with a leading zero often goes wrong when it passes through a spreadsheet, a database or a form that treats it as a number. The zero is part of the code, and losing it produces an invalid value.

    Why it happens

    In maths, 01234 and 1234 are the same number, so number formats drop the zero. A postcode is not a quantity; it is a label, and the zero matters. The same logic applies to phone numbers, ID numbers and product codes.

    Where it bites

    • opening a CSV file in a spreadsheet, which guesses the column type
    • importing into a database column defined as an integer
    • JSON or code that parses digit-only strings into numbers
    • form fields with a numeric input type
    • mail-merge and label printing

    The result is a code with too few digits, which is rejected by validation or misrouted; see common postcode mistakes.

    How to prevent it

    1. Define the database column as text (a string type), not an integer.
    2. In spreadsheets, set the column format to text before pasting or importing data.
    3. In forms, use a text input, optionally with a numeric keyboard hint, but do not convert the value.
    4. In code, keep the value as a string from input to storage.
    5. Validate length with the country rule, so a missing zero is noticed. See postcode validation: key concepts.

    Repairing damaged data

    If you already have stripped codes, you can pad them back to the standard length, but only if you know the country's rule and that every code should have that length. Do this carefully, because countries with variable lengths cannot be repaired by padding alone.

    Other characters that are lost

    Spreadsheets can also convert codes like "1E5" into scientific notation, or treat a hyphenated code as a date. All of these are signs that the field was not set as text. See also postcode formats in online forms.

    A note on UPCS codes

    UPCS codes combine letters, digits and hyphens, such as PK-1A2B-3C4D, so they should always be stored as text too.

    Frequently asked questions

    Why does my spreadsheet remove the zero at the start of a postcode?

    The software treats the value as a number, and numbers do not keep leading zeros. Format the column as text to preserve it.

    Is a postcode a number?

    No. It is an identifier. Even if it contains only digits, you do not do arithmetic with it, so it should be stored as text.