The CEP (Código de Endereçamento Postal) is Brazil’s 8-digit postal code, issued and maintained by Correios — the country’s national postal operator. Every address in Brazil has a CEP, from urban apartment blocks in São Paulo to remote villages in the Amazon basin. The code appears on utility bills, bank statements, e-commerce checkouts, government forms, and any application that needs to identify or route mail to a Brazilian address.
Validating a CEP in software is a surprisingly common task: payment gateways require it for address verification, logistics APIs route deliveries using it, and tax systems tie it to fiscal zones. This tool validates the format, decodes the geographic meaning of the 5-digit prefix, and classifies the 3-digit suffix — entirely offline, without querying any external service.
Structure of a CEP
A CEP is always 8 digits, written as NNNNN-NNN:
| Part | Digits | Meaning |
|---|---|---|
| Prefix | First 5 digits | Geographic range — encodes state and sub-region |
| Suffix | Last 3 digits | Address type (street, PO box, post office, etc.) |
The hyphen is a cosmetic separator only. Internally Correios stores and processes the raw 8-digit string without punctuation.
How the prefix encodes geography
Correios divides Brazil into contiguous numeric blocks, each assigned to a state or metropolitan sub-region. The blocks were allocated roughly from south-east to north, with the most densely populated areas (São Paulo, Rio de Janeiro) getting the widest ranges.
For example:
01000–09999— São Paulo capital20000–23799— Rio de Janeiro capital70000–73699— Distrito Federal (Brasília)90000–99999— Rio Grande do Sul
Within a state, blocks are further divided by municipality and street segment.
A prefix that falls in 80000–87999 is unambiguously in Paraná;
one in 50000–56999 is in Pernambuco. The validator decodes this mapping
from a static table that covers all 26 states plus the Distrito Federal.
How the suffix encodes address type
The 3 digits after the hyphen tell you what kind of delivery point the CEP represents:
| Suffix range | Type |
|---|---|
000 | General area / district — fallback CEP for an entire locality |
001–899 | Street-level CEP — specific street segment or block |
900–959 | PO Box (caixa postal) |
960–979 | Large-volume receiver (empresa de grande porte) |
980–999 | Correios post office |
A “street-level” CEP (001–899) is the most common type.
A locality CEP (000) is typically used when a village or rural area
does not have individual street CEPs — the single 000 code covers the whole settlement.
Worked example
CEP 01310-100 — Avenida Paulista, São Paulo:
- Prefix:
01310— falls in the range01000–09999, which maps to São Paulo capital (SP), macro-region Sudeste. - Suffix:
100— in the001–899range, so this is a street-level CEP assigned to a specific segment of Avenida Paulista. - Formatted output:
01310-100 - Verdict: Valid format, prefix in a known Correios range.
A second example: 20040-020 — Avenida Rio Branco, Rio de Janeiro:
- Prefix:
20040— range20000–23799, Rio de Janeiro capital (RJ), Sudeste. - Suffix:
020— street-level address. - Verdict: Valid.
An invalid example: 00001-000:
- Prefix:
00001— integer value 1, below the minimum assigned prefix of 1000. - Verdict: Unassigned — Correios has never allocated this prefix.
What this validator does and does not do
It does: confirm the CEP has exactly 8 digits, that its prefix is not in the permanently
unassigned 00000–00999 block, that the prefix matches a published Correios geographic range,
and what the suffix type indicates.
It does not: resolve the CEP to a street address, municipality, or neighbourhood — that requires a live API call. For full address resolution, use the open ViaCEP API or the official Correios search portal.
Privacy
The entire validation runs in JavaScript in your browser tab. No CEP or any other data you enter is transmitted, logged, or stored anywhere. The geographic range table is bundled locally — there are no network requests.