1001Ferramentas
๐Ÿ“‹Validators

CEST Code Validator

Validate CEST code format (XX.XXX.XX), 7 digits. Checks if segment (XX) is in 01-28 (official).

โ€”

CEST validation: format, lookup and NCM coherence

The CEST (Codigo Especificador da Substituicao Tributaria) is a 7-digit code that identifies products subject to ICMS Substituicao Tributaria (ICMS-ST) in Brazil. It was created by Convenio ICMS 92/2015 of the Confaz (Conselho Nacional de Politica Fazendaria) to standardize, across all Brazilian states, which goods fall into the ST regime and to which segment they belong.

Validating a CEST is more than a regex match. The code must (i) follow the canonical format, (ii) exist in the current Convenio ICMS 142/2018 annex (the consolidated table that superseded 92/2015) and (iii) be coherent with the product's NCM. A CEST entry without a compatible NCM is automatically rejected by Sefaz.

Anatomy of the 7 digits: segment + item + specification

CEST is canonically rendered as SS.III.EE and decomposes as follows:

  • Digits 1-2 (SS): the segmento. Confaz defines 28 segments numbered 01 to 28.
  • Digits 3-5 (III): the item within the segment. Numbered sequentially as Confaz adds products.
  • Digits 6-7 (EE): the especificacao. Discriminates variants of the same item โ€” 00 when no further specification is needed.

Example: CEST 03.002.00 = segment 03 (bebidas alcoolicas, exceto cerveja e chope) + item 002 (vinho) + specification 00 (no variant). Reading the code from left to right reveals the ST classification chain.

The 28 Confaz segments

Each segment groups thematically related products. The most common ones in everyday e-commerce:

  • 01 Autopecas โ€” 02 Bebidas alcoolicas, exceto cerveja e chope โ€” 03 Bebidas alcoolicas (vinho, espumante, destilados)
  • 04 Cervejas, chopes, refrigerantes, aguas e outras bebidas โ€” 05 Cigarros e outros derivados do fumo โ€” 06 Cimentos
  • 07 Combustiveis e lubrificantes โ€” 08 Energia eletrica โ€” 09 Ferramentas โ€” 10 Materiais de construcao
  • 11 Materiais de limpeza โ€” 12 Materiais eletricos โ€” 13 Medicamentos โ€” 14 Papeis
  • 15 Perfumaria e higiene pessoal โ€” 16 Produtos alimenticios โ€” 17 Produtos ceramicos โ€” 20 Produtos de papelaria
  • 21 Produtos eletronicos, eletroeletronicos e eletrodomesticos โ€” 22 Racoes para animais โ€” 23 Sorvetes โ€” 24 Tintas e vernizes
  • 26 Veiculos automotores โ€” 27 Veiculos de duas e tres rodas โ€” 28 Venda de mercadorias pelo sistema porta a porta

Three layers of CEST validation

// 1. Format
const re = /^\d{2}\.?\d{3}\.?\d{2}$/
if (!re.test(input)) return { ok: false, error: 'format' }
const cest = input.replace(/\./g, '')

// 2. Existence in Convenio ICMS 142/2018 annex
const row = cestTable.get(cest)
if (!row) return { ok: false, error: 'not in CEST table' }

// 3. NCM coherence
if (!row.ncmList.some(n => matchesNcmPrefix(productNcm, n))) {
  return { ok: false, error: 'CEST does not cover this NCM' }
}
return { ok: true, segment: row.segment, mva: row.mvaByUf }

ICMS-ST in plain terms

Substituicao Tributaria means that one taxpayer in the chain โ€” usually the manufacturer or importer โ€” pays the ICMS due on subsequent operations (wholesale and retail) on behalf of all downstream sellers. The CEST signals that the product is under ST and the MVA (Margem de Valor Agregado) โ€” a state-defined markup percentage โ€” is used to estimate the final retail price and compute the ICMS-ST due.

Not every Brazilian state adopts ST for every CEST: each UF chooses (and changes) its protocol. The same CEST might trigger ST in Sao Paulo and not in Para. Validators that aim to be production-grade must therefore also check the UF protocol, not just the existence of the CEST.

CEST requires NCM: the inseparable pair

The Confaz table maps every CEST to a list of compatible NCMs (often a list of NCM prefixes). A CEST cannot appear on an electronic invoice without an NCM, and the NCM must match at least one prefix in the CEST's whitelist. The most common Sefaz rejection here is code 806: "CEST informado nao corresponde ao NCM informado".

<det nItem="1">
  <prod>
    <NCM>22030000</NCM>
    <CEST>0300200</CEST>  <!-- vinho, segmento bebidas -->
  </prod>
</det>

Common errors and edge cases

  • Leading zeros stripped: CEST 0100100 typed as 100100 fails the regex; always normalize to 7 digits.
  • CEST without NCM: invoice systems must require NCM whenever a CEST is present.
  • Wrong segment: classifying a soft drink under segment 03 (alcoholic beverages) instead of 04 (cervejas, chopes, refrigerantes) is a frequent mistake.
  • Outdated table: Confaz publishes amendments through ICMS conventions; relying on the 2015 version misses items added by 142/2018 and later.
  • MEI confusion: MEI sellers are usually outside ST, but the CEST still must be informed if the product is in the table; the ICMS-ST simply will not be charged from the MEI.

FAQ

What if my product is not on the CEST table? It is not under ICMS-ST. The NF-e must omit the CEST tag entirely โ€” do not invent a placeholder.

Is CEST mandatory in every state? CEST is mandatory whenever the product is listed in the Convenio table, regardless of the UF. Whether ICMS-ST is actually charged depends on each UF's protocol.

Does CEST change the ICMS rate? No. CEST only identifies the product as subject to ST. The rate and MVA are defined by each UF's legislation, not by the CEST itself.

How do marketplaces (Mercado Livre, Magalu, B2W) handle CEST? They require the seller to declare CEST per SKU and validate it server-side before emitting the NF-e. A wrong CEST blocks the sale.

Where do I get the official CEST table? Annex of Convenio ICMS 142/2018 with its amendments, published on the Confaz portal. BrasilAPI also exposes a maintained mirror.

Related Tools