Billing Postal Code Generator
Generate valid billing postal codes and ZIP codes for 50+ countries. Supports US, UK, Canada, EU formats with region-aware prefixes.
About
Billing address validation failures cause 3 - 8% of e-commerce transaction declines. Payment processors cross-reference the postal code field against the card issuer's records using AVS (Address Verification System). A misformatted code - wrong length, invalid prefix, or illegal characters - triggers an immediate reject before the charge even reaches the bank. This tool generates structurally valid postal codes conforming to each country's format specification: 5-digit numeric for US ZIP codes with state-aware prefix ranges, alphanumeric ANA NAN patterns for Canadian FSA/LDU codes, and outward/inward splits for UK postcodes. Use it to populate test environments, QA billing forms, or validate regex patterns against real format constraints.
Generated codes follow documented format rules from Universal Postal Union (UPU) standards. They are syntactically correct but do not guarantee geographic existence. For US codes, prefixes map to valid state ranges (e.g., 100 - 149 for New York). Canadian codes exclude letters D, F, I, O, Q, U per Canada Post rules. UK codes respect the area letter system. This is test data generation, not a geocoding service. Confirm real-world deliverability through your postal authority's API.
Formulas
Postal code generation follows a format-template approach. Each country defines a pattern string where N represents a random digit (0 - 9) and A represents a random uppercase letter (A - Z). For constrained countries, prefix ranges narrow the randomization space.
For region-aware generation (e.g., US ZIP codes), the first k digits are sampled from a valid prefix range:
Where rangemin and rangemax are the lowest and highest valid prefix values for the selected state or region. Remaining digits are filled with uniform random values. The function randInt(a, b) uses crypto.getRandomValues for uniform distribution across [a, b].
Canadian codes exclude the letters {D, F, I, O, Q, U} from all positions, and further restrict the first character to valid FSA letters per province. Dutch codes exclude letter combinations SA, SD, SS from the suffix.
Reference Data
| Country | ISO Code | Format | Example | Length | Notes |
|---|---|---|---|---|---|
| United States | US | NNNNN | 10001 | 5 | State-prefixed ranges |
| United Kingdom | GB | A9 9AA / A99 9AA / AA9 9AA | SW1A 1AA | 6-8 | Outward + Inward codes |
| Canada | CA | A9A 9A9 | M5V 2T6 | 7 | No D, F, I, O, Q, U |
| Germany | DE | NNNNN | 10115 | 5 | Range 01001-99998 |
| France | FR | NNNNN | 75001 | 5 | Dept prefix (01-95, 2A/2B) |
| Australia | AU | NNNN | 2000 | 4 | State-based ranges |
| Japan | JP | NNN-NNNN | 100-0001 | 8 | Hyphenated 3+4 digits |
| India | IN | NNNNNN | 110001 | 6 | First digit = region (1-8) |
| Brazil | BR | NNNNN-NNN | 01001-000 | 9 | Hyphenated 5+3 digits |
| Netherlands | NL | NNNN AA | 1011 AB | 7 | No SA, SD, SS |
| Italy | IT | NNNNN | 00100 | 5 | Range 00010-98168 |
| Spain | ES | NNNNN | 28001 | 5 | Province prefix 01-52 |
| Sweden | SE | NNN NN | 111 22 | 6 | Space-separated |
| Norway | NO | NNNN | 0101 | 4 | Range 0001-9991 |
| Switzerland | CH | NNNN | 8001 | 4 | Range 1000-9658 |
| Poland | PL | NN-NNN | 00-001 | 6 | Hyphenated |
| Portugal | PT | NNNN-NNN | 1000-001 | 8 | Hyphenated 4+3 |
| Belgium | BE | NNNN | 1000 | 4 | Range 1000-9992 |
| Austria | AT | NNNN | 1010 | 4 | Range 1010-9992 |
| Denmark | DK | NNNN | 1000 | 4 | Range 0800-9990 |
| Finland | FI | NNNNN | 00100 | 5 | Range 00100-99999 |
| Ireland | IE | A99 A9A9 | D02 AF30 | 7 | Eircode format |
| Czech Republic | CZ | NNN NN | 100 00 | 6 | Space-separated |
| South Korea | KR | NNNNN | 03051 | 5 | Range 01000-63644 |
| Mexico | MX | NNNNN | 01000 | 5 | Range 01000-99998 |
| Russia | RU | NNNNNN | 101000 | 6 | Range 101000-999999 |
| China | CN | NNNNNN | 100000 | 6 | Range 100000-999999 |
| Singapore | SG | NNNNNN | 018956 | 6 | Range 010000-828888 |
| South Africa | ZA | NNNN | 2001 | 4 | Range 0001-9999 |
| New Zealand | NZ | NNNN | 6011 | 4 | Range 0110-9893 |
| Argentina | AR | ANNNNAA | C1043AAQ | 8 | CPA format |