Legal nature

Legal nature codes of the IBGE/CONCLA Natureza Jurídica 2021 table.

  • Parity matrix

Validate

Checks whether a legal nature code exists in the IBGE/CONCLA Natureza Jurídica 2021 table.

  • It accepts the 92 codes in force, plus the 8 codes that a past revision retired. legalNature.get tells them apart.
  • Accepts the 4 digits, a safe non-negative integer or the NNN-N mask. The mask is accepted only after the third digit, with any run of separators (whitespace, ., - or /) between the third and the fourth digit: "206.2", "206--2" and "206 - 2" are valid. Surrounding whitespace is ignored.
  • A separator anywhere else, or any other character, makes the value invalid: "2-0-6-2", "20.6.2", "2062a". Until 2.4.0 the separators were stripped from anywhere in the string, so "-2-0-6-2" was valid.
  • A number is read only when it is a safe non-negative integer (2062 is valid). A negative, fractional, non-finite or unsafe number is invalid. Until 2.4.0 the function accepted only strings.
  • Any value that is not a string or a number returns false.
ParameterTypeRequired
codestring | numberyes
returnsboolean

Check if a legal nature code exists in the official list, the IBGE/CONCLA "Natureza Jurídica 2021" table. Accepts a string with the 4 digits or with the NNN-N mask, or a non-negative safe integer.

  • A separator run (space, ., - or /) is only read between the third and the fourth digit, so '2-0-6-2' is rejected.
  • The 92 codes in force are accepted, plus the 8 a past revision retired. getLegalNature tells them apart (legacy: true).
import { isValidLegalNature } from '@brazilian-utils/brazilian-utils';

isValidLegalNature('2062'); // true
isValidLegalNature(2062); // true
isValidLegalNature('206-2'); // true
isValidLegalNature('2208'); // true (retired by a past revision, still accepted)
isValidLegalNature('9999'); // false
isValidLegalNature('2-0-6-2'); // false (a separator only fits after the third digit)

Source: CONCLA, Natureza Jurídica 2021 and its detailed structure PDF.

Code: brazilian-utils/javascript
Try it with JavaScript isValidLegalNature
The inputs start with the first shared case. Change one to see the new result.

Runs @brazilian-utils/brazilian-utils 2.5.0 in your browser.

Shared test cases (56) and the result in each library legalNature.isValid

Format

Formats a legal nature code as NNN-N. Use legalNature.isValid to check the code.

  • The digits are read from the value and the mask is applied as far as they go: "206" stays "206", "2062" becomes "206-2". options.pad first left-pads with zeros to 4 digits ("62" becomes "006-2").
  • Digits after the 4th are ignored, and other characters are dropped. A number is treated as the string of its digits, so it is padded only with pad.
  • A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number gives an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
  • Returns an empty string when there is nothing to format. Until 2.4.0 a value with no digits and pad: true returned "000-0".
ParameterTypeRequired
valuestring | numberyes
optionsFormatLegalNatureOptionsno
options.padbooleanno
returnsstring

Format a legal nature code. Use isValidLegalNature to check a code.

  • Options (FormatLegalNatureOptions): pad first left-pads the value with zeros to the 4 digits of a complete code (default false). An empty value, or one without digits, gives '' even with pad.
import { formatLegalNature } from '@brazilian-utils/brazilian-utils';

formatLegalNature('2062'); // 206-2
formatLegalNature(2062); // 206-2
formatLegalNature('206'); // 206 (masked as far as it goes)
formatLegalNature('62', { pad: true }); // 006-2 (padded to 4 digits first)
Code: brazilian-utils/javascript
Try it with JavaScript formatLegalNature
The inputs start with the first shared case. Change one to see the new result.

Runs @brazilian-utils/brazilian-utils 2.5.0 in your browser.

Shared test cases (19) and the result in each library legalNature.format

Parse

Removes legal nature formatting and keeps only digits, capped at 4 digits.

  • It does not left-pad anything. Returns an empty string when there is no digit at all (null and undefined included).
  • A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number gives an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
ParameterTypeRequired
valuestring | numberyes
returnsstring

Remove legal nature formatting, keep only digits, and cap the result to 4 digits.

import { parseLegalNature } from '@brazilian-utils/brazilian-utils';

parseLegalNature('206-2'); // '2062'
Code: brazilian-utils/javascript
Try it with JavaScript parseLegalNature
The inputs start with the first shared case. Change one to see the new result.

Runs @brazilian-utils/brazilian-utils 2.5.0 in your browser.

Shared test cases (7) and the result in each library legalNature.parse

Generate

Generates a random valid legal nature code (4 digits). It picks only among the 92 codes in force, never a retired one.

ParameterTypeRequired
returnsstring

Generate a random valid legal nature code. Only the 92 codes in force are drawn, never a retired one.

import { generateLegalNature } from '@brazilian-utils/brazilian-utils';

generateLegalNature(); // '2062'
Code: brazilian-utils/javascript
Try it with JavaScript generateLegalNature
The inputs start with the first shared case. Change one to see the new result.

Runs @brazilian-utils/brazilian-utils 2.5.0 in your browser.

Shared test cases (1) and the result in each library legalNature.generate

Look up

Looks up a legal nature code in the IBGE/CONCLA Natureza Jurídica 2021 table. Returns null for an unknown code.

  • Same input rules as legalNature.isValid: the 4 digits, a safe non-negative integer or the NNN-N mask, with any run of separators (whitespace, ., - or /) between the third and the fourth digit. "206.2" finds 2062. Surrounding whitespace is ignored.
  • A separator anywhere else ("2-0-6-2") or any other character ("2062a") returns null. Until 2.4.0 the separators were stripped from anywhere in the string.
  • A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number returns null. 2.4.0 stripped the sign and decimal point of a number too, so 206.2 found 2062.
  • No code starts with zero (the first digit is the category, 1 to 5), so nothing is padded: a number and the string of the same digits read the same.
  • The entry has the code, its description and its CONCLA category (given by the first digit): 1 Administração Pública, 2 Entidades Empresariais, 3 Entidades sem Fins Lucrativos, 4 Pessoas Físicas, 5 Organizações Internacionais e Outras Instituições Extraterritoriais.
  • A code that a past revision retired comes back with legacy: true and the currentCode it corresponds to today, or null when the revision that retired it published no successor (2100, 3050 and 3123). The 92 codes in force have legacy: false and no currentCode.
  • The retired codes and what each corresponds to today: 2076 to 2070, 2208 to 2275, 3042 to 3069, 3093 to 3999 and 5002 to 5010; 2100, 3050 and 3123 have no successor.
  • It returns null exactly when legalNature.isValid returns false.
ParameterTypeRequired
valuestring | numberyes
returnsLegalNature | null

Look a legal nature code up in the official IBGE/CONCLA table. Returns null for an unknown code.

  • The entry (LegalNature) also carries the CONCLA category of the code, given by its first digit.
  • A code a past revision retired comes back with legacy: true and the currentCode it corresponds to today, or currentCode: null when there is no successor (2100, 3050 and 3123). Codes in force have legacy: false and no currentCode.
Retired codeDescriptionCorresponds to
2076Sociedade Empresária em Nome Coletivo2070, the code the 2003.1 revision renumbered it to, same denomination
2100Sociedade Mercantil de Capital e Indústrianone, marked "categoria extinta" by the 2003.1 x 2009 correspondence
2208Entidade Binacional Itaipu2275 Empresa Binacional
3042Organização Social3069 Fundação Privada; the 2014 revision later created 3301 Organização Social (OS), where an entity qualified as one is classified today
3050Organização da Sociedade Civil de Interesse Público (Oscip)none, an Oscip is classified by the form it takes (3999 or 3069)
3093Unidade Executora (Programa Dinheiro Direto na Escola)3999 Associação Privada
3123Partido Políticonone, the 2014 revision split it into 3255, 3263 and 3271
5002Organização Internacional e Outras Instituições Extraterritoriais5010 Organização Internacional, the code it was opened into alongside 5029 and 5037
import { getLegalNature } from '@brazilian-utils/brazilian-utils';

getLegalNature('2062');
// {
//   code: '2062',
//   description: 'Sociedade Empresária Limitada',
//   category: { code: '2', description: 'Entidades Empresariais' },
//   legacy: false,
// }
getLegalNature('2208');
// {
//   code: '2208',
//   description: 'Entidade Binacional Itaipu',
//   category: { code: '2', description: 'Entidades Empresariais' },
//   legacy: true,
//   currentCode: '2275',
// }
getLegalNature('3123')?.currentCode; // null (retired without a successor)
getLegalNature('206-2')?.code; // '2062'
getLegalNature('206.2')?.category.description; // 'Entidades Empresariais'
getLegalNature(206.2); // null (a number is only read when it is a non-negative safe integer: write the dotted form as a string)
getLegalNature('0000'); // null

Source: CONCLA, Natureza Jurídica 2021.

Code: brazilian-utils/javascript
Try it with JavaScript getLegalNature
The inputs start with the first shared case. Change one to see the new result.

Runs @brazilian-utils/brazilian-utils 2.5.0 in your browser.

Shared test cases (17) and the result in each library legalNature.get

List

Returns the legal nature table as a map from code to description.

  • By default, it returns only the 92 codes in force (params.includeLegacy is false). The table is CONCLA's Natureza Jurídica 2021.
  • params.includeLegacy: true adds the 8 codes a past revision retired, 100 in all. legalNature.isValid and legalNature.get accept those codes either way.
  • It returns a fresh object on every call.
ParameterTypeRequired
paramsGetLegalNaturesParamsno
params.includeLegacybooleanno
returnsRecord<string, string>

Get the legal nature map keyed by code. Only the 92 codes in force are listed by default.

  • Options (GetLegalNaturesParams): includeLegacy (default false) adds the 8 retired codes.
import { getLegalNatures } from '@brazilian-utils/brazilian-utils';

const legalNatures = getLegalNatures();

legalNatures['2062']; // 'Sociedade Empresária Limitada'
Object.keys(legalNatures).length; // 92
legalNatures['2208']; // undefined (retired by a past revision)
getLegalNatures({ includeLegacy: true })['2208']; // 'Entidade Binacional Itaipu'
Code: brazilian-utils/javascript
Try it with JavaScript getLegalNatures
The inputs start with the first shared case. Change one to see the new result.

Runs @brazilian-utils/brazilian-utils 2.5.0 in your browser.

Shared test cases (2) and the result in each library legalNature.list

Get description

Returns the description of a legal nature code.

JavaScript does not have this function yet. Add it to the library.

Shared test cases (2) and the result in each library legalNature.getDescription

List by category

Returns every legal nature of a CONCLA category (the first digit of the code), sorted by code.

  • Categories: 1 Administração Pública, 2 Entidades Empresariais, 3 Entidades sem Fins Lucrativos, 4 Pessoas Físicas, 5 Organizações Internacionais e Outras Instituições Extraterritoriais.
  • category may be a string or a number: "2" and 2 return the same list. A prefix ("20"), a full code ("2062"), a padded value (" 2", "02") and a value outside 1 to 5 are not categories.
  • Only the codes in force are listed by default (options.includeLegacy is false).
  • options.includeLegacy: true adds the codes a past revision retired (2076, 2100 and 2208 in category 2, 3042, 3050, 3093 and 3123 in category 3, 5002 in category 5). They come back with legacy: true and the currentCode.
  • The result is a fresh array of fresh entries on every call.
  • Returns an empty list for an unknown category or a value that is not a string or a number.
ParameterTypeRequired
categorystring | numberyes
optionsGetLegalNaturesByCategoryOptionsno
options.includeLegacybooleanno
returnsLegalNature[]

Get every legal nature of a CONCLA category, the group given by the first digit of the code. The category is accepted as a string or as a number.

  • Categories: 1 Administração Pública, 2 Entidades Empresariais, 3 Entidades sem Fins Lucrativos, 4 Pessoas Físicas and 5 Organizações Internacionais e Outras Instituições Extraterritoriais.
  • Options (GetLegalNaturesByCategoryOptions): includeLegacy (default false) adds the retired codes of the category.
  • The entries come back sorted by code. An unknown category returns [].
import { getLegalNaturesByCategory } from '@brazilian-utils/brazilian-utils';

getLegalNaturesByCategory('4')[0];
// {
//   code: '4014',
//   description: 'Empresa Individual Imobiliária',
//   category: { code: '4', description: 'Pessoas Físicas' },
//   legacy: false,
// }
getLegalNaturesByCategory(4).length; // 6
getLegalNaturesByCategory('2').length; // 30
getLegalNaturesByCategory('2', { includeLegacy: true }).length; // 33
getLegalNaturesByCategory('9'); // []
Code: brazilian-utils/javascript
Try it with JavaScript getLegalNaturesByCategory
The inputs start with the first shared case. Change one to see the new result.

Runs @brazilian-utils/brazilian-utils 2.5.0 in your browser.

Shared test cases (17) and the result in each library legalNature.listByCategory

Official sources

See also CNPJ

Last updated on

On this page