Area code (DDD)
Telephone area codes (DDD) in use under the Anatel Plano Geral de Numeração, and the states they serve.
Decode
- JavaScript library
- Python library
- Go library3 cases fail
- Ruby library2 cases fail
- Rust library
- .NET library2 cases fail
- Erlang library
Returns the state and region that a DDD (area code) belongs to, among the 67 DDDs in use under the Anatel Plano Geral de Numeração.
areaCodemay be a string or a non-negative integer.- A string has every character that is not a digit removed first, as in 2.4.0:
"(0xx11)"and" 11 "resolve to 11. - The result carries the DDD, the state it is seated in (code and name), its region (code and name) and every state it serves.
- The seat is the state of the city the code was allocated around, not necessarily the state with most of its municipalities: DDD 61 is seated in DF, which holds only 1 of its 13 municipalities (Brasília).
- Four DDDs straddle a state border (61, 42, 47 and 49). For these, the list of states also has the other state, with the seat first: 61 gives
DF, GO, 42 givesPR, SC, 47 and 49 giveSC, PR. - Returns
nullfor a DDD not in use, a negative or non-integer number, or anything else.
| Parameter | Type | Required |
|---|---|---|
areaCode | string | number | yes |
| returns | AreaCodeInfo | null |
Get the state and region a Brazilian DDD (area code) belongs to, out of the 67 DDDs in use under the Anatel Plano Geral de Numeração. Accepts a string or a non-negative integer.
- A string has any non-digit characters stripped, so
'(11)','0xx11'and'DDD 11'are the DDD 11. - Returns an
AreaCodeInfo:areaCode,stateCode,stateName,regionCode,regionNameandstateCodes. Returnsnullwhen the DDD is not in use. stateCodeis the state the DDD is seated in. For the four DDDs that straddle a border (61, 42, 47 and 49)stateCodesalso lists the other state, the seat first.
import { getAreaCodeInfo } from '@brazilian-utils/brazilian-utils';
getAreaCodeInfo('11');
// { areaCode: 11, stateCode: 'SP', stateName: 'São Paulo', regionCode: 'SE', regionName: 'Sudeste', stateCodes: ['SP'] }
getAreaCodeInfo(21);
// { areaCode: 21, stateCode: 'RJ', stateName: 'Rio de Janeiro', regionCode: 'SE', regionName: 'Sudeste', stateCodes: ['RJ'] }
getAreaCodeInfo('61');
// { areaCode: 61, stateCode: 'DF', stateName: 'Distrito Federal', regionCode: 'CO', regionName: 'Centro-Oeste', stateCodes: ['DF', 'GO'] }
getAreaCodeInfo('00'); // null
getAreaCodeInfo('(0xx11)'); // the same as '11'
getAreaCodeInfo(-11); // null
getAreaCodeInfo(1.1); // nullSource: Resolução Anatel nº 749/2022, Anatel Códigos Nacionais, Anatel table of the Códigos Nacionais by municipality (21/09/2026).
Code: brazilian-utils/javascriptTry it with JavaScript getAreaCodeInfo
Shared test cases (13) and the result in each library areaCode.getInfo
Get by municipality code
Returns the DDD (area code, the Código Nacional of the Plano Geral de Numeração) that a municipality dials, given its 7-digit IBGE code.
codeis read asmunicipality.getByCodereads it: a string with every non-digit removed, or a non-negative integer.- Each of the 5,571 municipalities has exactly one DDD, so
nullonly means that the code is not a municipality. - A DDD mostly follows state lines. The exceptions: 61, the DDD of Brasília, also covers 12 municipalities of Goiás. Porto União (SC) dials 42, Rio Negro (PR) dials 47 and Barracão (PR) dials 49.
areaCode.getInfogives the state and region the DDD is seated in.- The table comes from the Anatel Códigos Nacionais file of 21/09/2026, rows in force only.
| Parameter | Type | Required |
|---|---|---|
code | string | number | yes |
| returns | number | null |
Get the DDD (area code) a Brazilian municipality dials, given its 7-digit IBGE code, from the Anatel table of the Códigos Nacionais in force.
- Accepts the code the way
getMunicipalityByCodedoes: a string (any non-digit characters stripped) or a non-negative integer. - Returns the DDD as a number, or
nullwhen the code is not a municipality. Every one of the 5,571 municipalities has exactly one DDD. - A DDD mostly follows state lines. The exceptions: 61 also covers 12 municipalities of Goiás around Brasília, and Porto União (SC) dials 42, Rio Negro (PR) 47 and Barracão (PR) 49.
import { getAreaCodeByMunicipalityCode } from '@brazilian-utils/brazilian-utils';
getAreaCodeByMunicipalityCode('3550308'); // 11 (São Paulo/SP)
getAreaCodeByMunicipalityCode(3304557); // 21 (Rio de Janeiro/RJ)
getAreaCodeByMunicipalityCode('4122305'); // 47 (Rio Negro/PR)
getAreaCodeByMunicipalityCode('0000000'); // nullSource: Resolução Anatel nº 749/2022, Anatel Códigos Nacionais, Anatel table of the Códigos Nacionais by municipality (21/09/2026).
Code: brazilian-utils/javascriptTry it with JavaScript getAreaCodeByMunicipalityCode
Shared test cases (21) and the result in each library areaCode.getByMunicipalityCode
List by state
- JavaScript library
- Python library
- Go library
- Ruby library
- Rust library1 case fails
- .NET library
- Erlang library
Returns every DDD (area code) that serves a state, sorted in ascending order.
stateCodeis matched ignoring case and surrounding whitespace, as it already was in 2.4.0.- A DDD that straddles a border is listed under every state it serves.
- Returns an empty list when
stateCodeis not a Brazilian state.
| Parameter | Type | Required |
|---|---|---|
stateCode | string | yes |
| returns | number[] |
Get every DDD (area code) that serves a given Brazilian state, under the Anatel Plano Geral de Numeração. The match is case-insensitive and the result is sorted in ascending order.
- Returns
[]whenstateCodedoes not match a Brazilian state. - A DDD that straddles a border (the same four as
getAreaCodeInfo) is listed under every state it serves.
import { getAreaCodesByState } from '@brazilian-utils/brazilian-utils';
getAreaCodesByState('SP'); // [11, 12, 13, 14, 15, 16, 17, 18, 19]
getAreaCodesByState('ac'); // [68]
getAreaCodesByState('DF'); // [61]
getAreaCodesByState('GO'); // [61, 62, 64]
getAreaCodesByState('SC'); // [42, 47, 48, 49]
getAreaCodesByState('XX'); // []Source: Resolução Anatel nº 749/2022, Anatel Códigos Nacionais, Anatel table of the Códigos Nacionais by municipality (21/09/2026).
Code: brazilian-utils/javascriptTry it with JavaScript getAreaCodesByState
Shared test cases (14) and the result in each library areaCode.listByState
Official sources
- informacoes.anatel.gov.br/legislacao/resolucoes/…/1641-resolucao-749
- gov.br/anatel/pt-br/…/codigos-nacionais
- informacoes.anatel.gov.br/paineis/areas-tarifarias/…/codigos-nacionais
- anatel.gov.br/dadosabertos/paineis_de_dados/…/pgcn.zip
- servicodados.ibge.gov.br/api/docs/…/localidades
See also Phone, States (UF), Municipalities
Last updated on
