United States Postal Code Format

A country-level reference for how postal and ZIP codes are structured in United States.

Postal format
US : NNNNN[-NNNN]
Library format pattern
^[0-9]{5}([0-9]{4})?$
Format test inputs (not verified assigned codes)
12345, 12345-7689

These strings come from software tests, not a directory of assigned postal codes. They are checked using the library's country-specific separator rules before display. A format match does not establish assignment or deliverability.

Check a postal code format

Enter a code to compare its syntax with the pattern above. The checker ignores letter case and trims outer whitespace. ASCII spaces and hyphens are removed before matching. Other internal whitespace is preserved. These are the separator rules declared by this library version.

A format match does not confirm assignment, an address, or delivery availability.

Writing a ZIP+4 on a mailing label

Use 02108-1234 as a formatting exercise. The first five digits form the ZIP Code. The next two identify a sector, and the last two identify a segment within it. Preserve the leading zero when moving the value into a spreadsheet or shipping form. The four added digits here are illustrative; obtain the actual suffix for the full delivery address from USPS.

Try 02108-1234, 021081234 and 2108-1234 in the checker. Its separator handling lets the first two pass. The third has lost a digit and fails. For the mailing label, USPS specifies a hyphen after the fifth digit when using ZIP+4. A passing nine-digit input still needs that formatting and an address match.

USPS Domestic Mail Manual, section 1.8.2 ยท Look up the ZIP Code by address

Source and limits

The format description, pattern, and test inputs are imported from postal-codes-js 2.5.2 (Apache-2.0). Inputs originate in the library's TestData.Valid fixtures. Their label means they were supplied for software testing; it does not establish that a postal service assigned them.

This is a versioned software reference, not a live postal directory. We have not independently verified every country's current rules. For an actual shipment, check the full address and postcode with the destination postal operator or carrier.