NCM

Nomenclatura Comum do Mercosul: the goods classification codes published by Siscomex.

  • Parity matrix

Validate

Checks whether an NCM code exists in the current table that Siscomex publishes.

  • A value written as bare digits, as a string or as a number, is left-padded with zeros to 8: 1012100, "1012100" and "01012100" are the same code. A masked value is read as written (101.21.00 is invalid).
  • Same input rules as cbo.isValid, with 8 digits and the NNNN.NN.NN mask, including a run of separators between the groups: 2203..00.00 is valid. Until 2.4.0 a single separator was accepted and 2203..00.00 was rejected.
  • The table is the file "Vigente em 26/09/2026" of the Portal Único Siscomex (Resolução Gecex nº 926/2026), with 10,515 codes.
ParameterTypeRequired
valuestring | numberyes
returnsboolean

Check if an NCM (Nomenclatura Comum do Mercosul) code exists in the current table published by Siscomex/MDIC.

  • Same rules as isValidCbo, with 8 digits and the NNNN.NN.NN mask.
import { isValidNcm } from '@brazilian-utils/brazilian-utils';

isValidNcm('8471.30.12'); // true
isValidNcm('84713012'); // true
isValidNcm(1012100); // true (padded to 8 digits, so this is '01012100')
isValidNcm('1012100'); // true (padded the same way a number is)
isValidNcm('00000000'); // false
isValidNcm('abc01012100'); // false (not a documented form)
isValidNcm(-84713012); // false (not a non-negative safe integer)

Source: NCM nomenclature published by the Portal Único Siscomex; the bundled 10,515 codes are those of the file "Vigente em 26/09/2026" (Resolução Gecex nº 926/2026).

Code: brazilian-utils/javascript
Try it with JavaScript isValidNcm
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 ncm.isValid

Format

Formats an NCM code with the mask NNNN.NN.NN. Only the structure changes (use ncm.isValid to check the code).

  • Same rules as cnae.format. options.pad first left-pads the value with zeros to 8 digits. A value without digits, and null or undefined, returns an empty string even with pad; until 2.4.0 pad turned an empty value into the zero mask (0000.00.00).
  • 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).
ParameterTypeRequired
valuestring | numberyes
optionsFormatNcmOptionsno
options.padbooleanno
returnsstring

Format an NCM (Nomenclatura Comum do Mercosul) code. Only the structure changes; use isValidNcm to check a code against the table.

  • Options (FormatNcmOptions): pad (default false) first left pads the value with zeros to the 8 digits of a complete code. An empty value, or one without digits, gives '' even with pad.
  • Same rules as formatCnae, with the NNNN.NN.NN mask.
import { formatNcm } from '@brazilian-utils/brazilian-utils';

formatNcm('84713012'); // 8471.30.12
formatNcm('8471'); // 8471 (masked as far as it goes)
formatNcm('847130'); // 8471.30
formatNcm('8471', { pad: true }); // 0000.84.71 (padded to 8 digits first)
formatNcm('abc8471'); // 8471 (only the digits are read)
formatNcm(-84713012); // '' (not a non-negative safe integer)
Code: brazilian-utils/javascript
Try it with JavaScript formatNcm
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 (31) and the result in each library ncm.format

Parse

Removes NCM formatting and keeps only digits, capped at 8 digits.

  • The function does not left-pad the value. It keeps a partial code as written.
  • 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 returns an empty string (2.4.0 read the digits of any number, sign and decimal point dropped).
ParameterTypeRequired
valuestring | numberyes
returnsstring

Remove NCM (Nomenclatura Comum do Mercosul) formatting, keep only digits, and cap the result to the 8 digits of a complete code.

  • Same rules as parseCbo: nothing is left padded here.
import { parseNcm } from '@brazilian-utils/brazilian-utils';

parseNcm('8471.30.12'); // '84713012'
parseNcm('8471'); // '8471' (a partial code is kept as written)
Code: brazilian-utils/javascript
Try it with JavaScript parseNcm
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 (10) and the result in each library ncm.parse

Official sources

Last updated on

On this page