1001Ferramentas
🏙️Generators

IBGE Municipality Code Generator

Generate fake IBGE municipality code (7 digits: UF + 5 + DV). For mockups and state validation tests.


  

IBGE municipal code: Brazil's 7-digit city identifier

The IBGE municipal code is a 7-digit numeric identifier assigned to every one of Brazil's 5,570 municipalities (figure stable since the 2022 Census, after Mojuí dos Campos in Pará was created in 2013, raising the count from 5,569). Maintained by the Brazilian Institute of Geography and Statistics, it is the canonical key tying a city to fiscal, statistical and georeferenced systems across the federation.

How the 7 digits are structured

The first two digits are the UF code (state), and the remaining five digits are sequential within that UF. Some flagship examples:

  • 3550308 — São Paulo (SP capital)
  • 3304557 — Rio de Janeiro
  • 5300108 — Brasília (DF)
  • 3106200 — Belo Horizonte
  • 4205407 — Florianópolis
  • 2304400 — Fortaleza
  • 5208707 — Goiânia
  • 1100205 — Porto Velho

Where the code is required

The municipal code is read by every official Brazilian system: the cMun field on an NF-e, the e-Social register, IRRF withholding files, the FGTS deposit slip, the annual RAIS report and any georeferenced filing. IBGE exposes the full catalogue at servicodados.ibge.gov.br/api/v1/localidades/municipios as public JSON — many ERP and accounting platforms simply mirror that endpoint.

Municipality, city, district — what differs

A município is the full administrative territory (rural areas, distritos and the urban seat). The cidade is just the urban seat — the perimeter where the prefecture sits. A distrito is a sub-division of the município, often a small town away from the seat (Petrópolis-RJ, for instance, contains Cascatinha, Itaipava and others). The IBGE code identifies the município, not the cidade nor the distrito.

Curiosities

  • Largest by area: Altamira (PA) at 159,696 km² — bigger than England.
  • Smallest by area: Santa Cruz de Minas (MG) at just 3.565 km².
  • 27 capitals: 26 state capitals plus Brasília. Mato Grosso do Sul, dismembered from MT in 1977, took Campo Grande as its capital; MT kept Cuiabá.

FAQ

Does the code change when a municipality is renamed? No. The code is permanent; only the name field in the IBGE registry is updated. This avoids breaking historical fiscal series.

Can I use the IBGE code to derive a postal code (CEP)? No. CEPs follow their own logic, managed by Correios; the mapping is many-to-many (one município has many CEP ranges, and some CEPs straddle borders).

How do I look up a name from a code? Hit servicodados.ibge.gov.br/api/v1/localidades/municipios/{code} — returns the official name, microregion, mesoregion and UF.

Are the codes generated by this tool real? Yes — they are drawn from the official IBGE list, useful for seeding mocks of NF-e, e-Social or any system that validates against the catalogue.

Related Tools