CBO
Classificação Brasileira de Ocupações: the occupation codes of the current CBO 2002 release of the MTE.
Validate
Checks whether a CBO code exists in the official CBO 2002 occupation table.
- Accepts the 6 digits, the
NNNN-NNmask or a non-negative integer. A masked string may have any run of separators (space,.,-or/) between the groups:2124--05is valid. Until 2.4.0 the mask had a single separator and2124--05was rejected. - Separators are accepted only at the boundary between the groups:
2124-0-5and21-2405are invalid. Surrounding whitespace is ignored. - Bare digits (string or number) are left-padded with zeros to 6. A masked value is read as written.
- Any other string is rejected. The function does not pick out its digits.
- A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number is invalid.
- The table follows the current release of the MTE, the "Estrutura CBO (CSV)" files of 10/07/2026 with 2,725 occupations. 2.4.0 used the older gov.br CSV of 06/06/2025 (2,694 occupations).
- A code the MTE retired is no longer valid. 225142, 322105, 322115, 322120, 322125 and 782820 were valid in 2.4.0 and are invalid now. Some moved to new codes: Técnico em acupuntura is now 322705.
- 37 occupations were added, among them 782325 (Motorista de transporte por aplicativos), 142360 and 225157.
Check if a CBO (Classificação Brasileira de Ocupações) code exists in the official CBO 2002 table.
- Accepts a string with the 6 digits or with the
NNNN-NNmask, or a number. - A masked string may have any run of separators (space,
.,-or/) between the groups. Any other string is rejected instead of having its digits picked out. - Bare digits are left padded with zeros to 6, as a string or as a number. A masked value is read as written.
import { isValidCbo } from '@brazilian-utils/brazilian-utils';
isValidCbo('2124-05'); // true
isValidCbo('212405'); // true
isValidCbo(212405); // true
isValidCbo(10205); // true (padded to 6 digits, so this is '010205')
isValidCbo('10205'); // true (padded the same way a number is)
isValidCbo('000000'); // false
isValidCbo('2124abc05'); // false (not a documented form)
isValidCbo(-212405); // false (not a non-negative safe integer)Source: CBO 2002 tables published by the MTE ("Estrutura CBO (CSV)", files of 10/07/2026, 2,725 occupations).
Shared test cases (38) and the result in each library cbo.isValid
Format
Formats a CBO code with the mask NNNN-NN. Only the structure changes (use cbo.isValid to check the code against the table).
- The mask is applied as far as the digits go, which is what an input being typed into needs.
options.pad(defaultfalse) first left-pads the value with zeros to 6 digits. A number is treated as the string of its digits, so it is padded only withpad.- A string is read for its digits: other characters are dropped and digits after the last one of the mask are ignored.
- Returns an empty string when there is no digit at all, also with
pad.nullandundefinedreturn an empty string too. - A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns an empty string.
- New in 2.5.0 (#615), so every masked classification code has its formatter.
Format a CBO (Classificação Brasileira de Ocupações) code into the NNNN-NN mask. Only the structure changes; use isValidCbo to check a code against the table.
- Options (
FormatCboOptions):pad(defaultfalse) first left pads the value with zeros to the 6 digits of a complete code. Without it the mask is applied as far as the value goes. An empty value, or one without digits, gives''even withpad. - Characters outside the mask are dropped, and a number is read as the string of its digits only when it is a non-negative safe integer: a negative, fractional or unsafe number returns
''. Returns''when there is no digit at all.
import { formatCbo } from '@brazilian-utils/brazilian-utils';
formatCbo('212405'); // 2124-05
formatCbo('21240'); // 2124-0 (masked as far as it goes)
formatCbo('10205', { pad: true }); // 0102-05 (padded to 6 digits first)
formatCbo('abc212405'); // 2124-05 (only the digits are read)
formatCbo(-212405); // '' (not a non-negative safe integer)Source: CBO 2002 tables published by the MTE, which print the codes as NNNN-NN.
Shared test cases (26) and the result in each library cbo.format
Parse
Removes CBO formatting and keeps only digits, capped at 6 digits.
- It does not left-pad anything. A leading zero must be written out.
- Returns an empty string when there is no digit at all (
nullandundefinedincluded). - A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
Remove CBO (Classificação Brasileira de Ocupações) formatting, keep only digits, and cap the result to 6 digits.
- Nothing is left padded: the leading zero of a code such as
010205has to be written out. UsegetCboorisValidCboto look an occupation up.
import { parseCbo } from '@brazilian-utils/brazilian-utils';
parseCbo('2124-05'); // '212405'Shared test cases (10) and the result in each library cbo.parse
Look up
Looks up a CBO code in the CBO 2002 occupation table and returns its code and official title (description).
- Same input rules as
cbo.isValid. The returned code is the 6 bare digits. - Returns
nullfor an unknown code or a value not written in one of the accepted forms. A run of separators between the groups is accepted, as incbo.isValid(2124--05gives the entry; until 2.4.0 it gavenull). - It returns
nullexactly whencbo.isValidreturnsfalse. The table and its titles follow the current MTE release (10/07/2026). 106 titles changed from 2.4.0, and codes the MTE retired returnnull.
Look a CBO (Classificação Brasileira de Ocupações) code up and get its official occupation title. The result is a Cbo record: { code, description }.
- Same rules as
isValidCbo. Returnsnullwhen the code is unknown or the value is not in a documented form.
import { getCbo } from '@brazilian-utils/brazilian-utils';
getCbo('2124-05'); // { code: '212405', description: 'Analista de desenvolvimento de sistemas' }
getCbo(10205); // { code: '010205', description: 'Oficial da aeronáutica' } (padded to 6 digits)
getCbo('10205'); // { code: '010205', description: 'Oficial da aeronáutica' } (padded the same way)
getCbo('000000'); // null
getCbo('2124abc05'); // null (not a documented form)Source: CBO 2002 tables published by the MTE ("Estrutura CBO (CSV)", files of 10/07/2026, 2,725 occupations).
Shared test cases (30) and the result in each library cbo.get
Official sources
Last updated on
