ZIP Code Format Guide
Complete guide to US ZIP code formats, types, leading zeros, ZIP+4, and storage best practices.
The standard ZIP code is a 5-digit number (e.g., 10001). Introduced in 1963, ZIP stands for "Zone Improvement Plan." The first digit represents a national area, the next two a sectional center facility, and the final two a local post office or delivery area.
The ZIP+4 code adds a hyphen and 4 additional digits after the 5-digit base (e.g., 10001-0001). The +4 identifies a specific city block, floor, or group of mailboxes. Required for bulk mailing and improves delivery speed.
The full 11-digit code includes the 5-digit ZIP, the 4-digit extension, and a 2-digit delivery point code. Used internally by USPS equipment for automated sorting.
- →Always use 5 digits — pad with leading zeros if needed (e.g., 01234, not 1234)
- →ZIP codes run from 00501 (Holtsville, NY) to 99950 (Ketchikan, AK)
- →Write the city, state, and ZIP on the same line in USPS format
- →Use UPPERCASE for all address elements in printed mail
- →Leave two spaces between state abbreviation and ZIP code
- →USPS prefers the ZIP+4 format for business mail
- →Never use punctuation within the ZIP code itself
- →Military ZIP codes (APO/FPO/DPO) follow the same 5-digit format
5-Digit vs ZIP+4
Full comparison of 5-digit standard ZIP and 9-digit ZIP+4 extended formats.
Leading Zero Alert
Critical guide on preserving leading zeros — the #1 ZIP code storage error in databases.
Regex Patterns
Ready-to-use regex validation patterns for JavaScript, Python, SQL, and more.
US ZIP Code Leading-Zero States and Their ZIP Prefix Ranges
8 states + Puerto Rico + USVI have ZIPs starting with 0 — must be stored as text
US ZIP Code Format Guide — Everything About ZIP Code Structure and Storage
Understanding the correct format for US ZIP codes is foundational to building reliable address systems, data pipelines, and form validations. ZIP codes look deceptively simple — just 5 digits — but the details of format, type, leading zeros, ZIP+4 extensions, and storage conventions are sources of frequent errors in real-world applications. This guide covers every aspect of US ZIP code formatting and best practices.
The Basic 5-Digit ZIP Code Format
A standard US ZIP code is exactly 5 digits, formatted as NNNNN. Each digit position carries geographic meaning. The first digit (0–9) identifies one of 10 national delivery regions. The second and third digits together identify a Sectional Center Facility (SCF) — a regional mail processing hub. The fourth and fifth digits identify the specific local delivery zone served by a post office.
Valid 5-digit ZIP codes range from 00001 to 99999, but only approximately 42,074 values in this range are active. Many 5-digit numbers are not assigned to any ZIP code. Format validation (checking that input is 5 digits) is necessary but not sufficient — always follow with a database lookup to confirm the ZIP is active.
The ZIP+4 Extended Format
The full ZIP+4 format adds a hyphen and 4 additional digits to the 5-digit ZIP: NNNNN-NNNN. The 4-digit suffix (called the "add-on code") narrows the delivery point to a specific city block, building, or P.O. Box. ZIP+4 format enables delivery point precision that is used for postal workshopping and barcode sorting.
Using ZIP+4 on bulk mailings qualifies mailers for significant USPS postage discounts. Presort Standard mail and Presort First-Class mail require ZIP+4 or delivery point barcodes. The discount can be 10–20 cents per piece — meaningful at scale for organizations mailing thousands of pieces monthly.
Regex for ZIP+4 validation: '^d{5}(-d{4})?$' in JavaScript, 'r'^d{5}(-d{4})?$'' in Python. This accepts either 5-digit or full ZIP+4 format.
The Leading Zero Problem: The Most Common ZIP Code Error
ZIP codes in eight states, Puerto Rico, and the US Virgin Islands begin with the digit 0: Connecticut (060–069), Maine (039–049), Massachusetts (010–027), New Hampshire (030–038), New Jersey (070–089), Rhode Island (028–029), Vermont (050–059), and parts of New York (100 and adjacent ranges), plus Puerto Rico (006–009) and US Virgin Islands (008).
When a ZIP code like "02134" (Boston, MA) is stored as an integer in a database or spreadsheet, the leading zero is silently stripped, producing "2134" — a 4-digit value that is not a valid ZIP code and will fail all lookup operations. This error causes silent data corruption that can be difficult to detect and expensive to remediate.
Prevention: Always declare ZIP code columns as VARCHAR(5) or TEXT in SQL databases. In Python, represent ZIP codes as strings from the moment they arrive — never parse them with 'int()'. In JavaScript, treat ZIP input values as strings and never call 'parseInt()' on a ZIP code. In Excel, format the cell as Text before entering ZIP data, or enter with a leading apostrophe to force text treatment.
Restoration: If you have a dataset with truncated 4-digit ZIP codes (former leading-zero ZIPs), restore them by zero-padding to 5 digits: in SQL: 'LPAD(zip_code::TEXT, 5, '0')'; in Python: 'zip_str.zfill(5)'; in JavaScript: 'zip.padStart(5, '0')'. Then validate the restored ZIPs against the USPS database.
ZIP Code Types and Their Format Implications
All ZIP codes share the same 5-digit format regardless of type, but their type affects how they should be used. Standard (S) ZIP codes serve residential and business addresses and can receive all types of mail and packages. P.O. Box (B) ZIP codes serve post office box customers only — physical parcels cannot be delivered to a P.O. Box ZIP without a separate street address. Unique (U) ZIP codes are assigned to large organizations (government agencies, large corporations, universities) that receive enough mail to warrant their own ZIP. Military (M) ZIP codes serve APO (Army Post Office), FPO (Fleet Post Office), and DPO (Diplomatic Post Office) addresses routed through military postal networks.
Storing ZIP Codes in Databases
The correct column definition in SQL: 'zip_code VARCHAR(5) NOT NULL CHECK (zip_code ~ '^d{5}$')'. This enforces 5-digit format at the database level. For ZIP+4, use 'VARCHAR(10)' with check constraint 'CHECK (zip_code ~ '^d{5}(-d{4})?$')'. In application code (Python/Django): 'models.CharField(max_length=5, validators=[RegexValidator(r'^d{5}$')])'. Never use 'models.IntegerField()' or 'models.PositiveIntegerField()' for ZIP codes.
Input Masking and User Experience
Web forms can guide users to correct ZIP format with input masking: restrict the ZIP field to numeric input only, enforce a 5-character maximum, and show an error immediately if the user enters non-digits or fewer/more than 5 characters. For ZIP+4 fields, use a split input (5 digits, hyphen, 4 digits) rather than a single 10-character field — this prevents format errors and is clearer to users. After the user completes the ZIP field, auto-populate city and state using a ZIP lookup API to confirm the ZIP is valid and reduce downstream data quality issues.
ZIP Code Format in Different Systems
Different systems handle ZIP codes with different quirks. USPS systems use 5-digit and ZIP+4 formats as described. Canadian postal codes look similar but use a completely different format (ANA NAN — alternating letters and digits, e.g., K1A 0B1) and are distinct from US ZIPs. UK postcodes (postcode) use yet another format. When building international address systems, ensure your data model can distinguish US ZIP codes from non-US postal codes and apply the correct format validation rules for each country.
🔗 Related ZIP Tools
View all tools →Frequently Asked Questions
Real questions from users — answered with detail and precision.
What is the correct format for a US ZIP code?▼
What regex validates a US ZIP code?▼
Why should ZIP codes be stored as VARCHAR instead of INT?▼
What states have ZIP codes starting with 0?▼
What is a ZIP+4 code and when should I use it?▼
How do I restore truncated ZIP codes that lost their leading zero?▼
What are the four ZIP code types?▼
Can ZIP codes contain letters?▼
How should I handle ZIP code input in web forms?▼
What is the maximum length of a US ZIP code field?▼
How often does USPS change ZIP codes?▼
Is this guide free?▼
TOOLTRIO — Free ZIP Code Tool Suite
TOOLTRIO (also searched as Tool Trio, ToolTrio, Trio Tools) is a free suite of 35+ US ZIP code tools. No signup, no rate limits. Every tool is free forever on tooltrio.com.
