1001Ferramentas
๐Ÿ†”Validators

CGC (Old CNPJ) Validator

Validate format and check digit of CGC (former Brazilian Tax Registry, predecessor to CNPJ). Same math rules.

โ€”

CGC: the pre-1998 Brazilian corporate taxpayer ID and its relationship to CNPJ

The CGC (Cadastro Geral de Contribuintes) is the historical name of the Brazilian corporate taxpayer registry that the Receita Federal used before 1998. In that year, Instrucao Normativa SRF 27/1998 officially renamed the document to CNPJ (Cadastro Nacional da Pessoa Juridica). The 14-digit numeric structure, the modulo 11 check-digit algorithm and the underlying registry remained identical: any historical CGC number is, mathematically and legally, a valid CNPJ today.

Before being called CGC the registry had a Ministry of Finance prefix and was sometimes referenced as CGC-MF (Cadastro Geral de Contribuintes do Ministerio da Fazenda). The change to CNPJ was part of a broader modernization that included the launch of the unified PIS/PASEP database and preparation for the future SPED electronic bookkeeping system in the 2000s. The corresponding move for natural persons had already happened earlier โ€” the CIC (Cartao de Identificacao do Contribuinte), which began in 1968, was renamed to CPF in the 1970s.

Structure of the 14 digits and modulo 11 algorithm

Both CGC and CNPJ use 14 numeric digits in the mask XX.XXX.XXX/YYYY-ZZ:

  • Digits 1 to 8: company base number, assigned sequentially by the Receita Federal.
  • Digits 9 to 12: branch or order code. 0001 for the matriz (headquarters), 0002 onwards for each filial.
  • Digits 13 and 14: the two check digits computed with modulo 11.

The check-digit algorithm uses two passes of weights:

  • DV1: multiply digits 1 to 12 by weights 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, sum, take mod 11. If the remainder is less than 2, DV1 = 0; otherwise DV1 = 11 - remainder.
  • DV2: append DV1 and multiply digits 1 to 13 by weights 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2; apply the same rule.

This validator runs that algorithm against the 14 digits you type, exactly as if you were validating a modern CNPJ. The CGC label is a labeling/UX choice: contracts, public records and ERP screens from before 1998 still use the word CGC, and the tool helps confirm that those legacy numbers continue to be well-formed under the present-day registry.

Where you still see CGC in 2026

  • Legacy ERP systems: older Brazilian software (SAP R/3 localizations from the 1990s, Oracle EBS, custom Delphi systems) often still labels the company tax ID field as CGC. Migration to the CNPJ label is incomplete in many on-prem installations.
  • Public-sector archives: municipal and state contracts signed before 1998 (works concessions, supply agreements, judicial deposits) reference the contractor by CGC. Digitization projects scan these documents and validators are used to confirm the OCR output.
  • Historical document parsing: legal-tech startups that extract data from old certidoes, escrituras and processo numbers must accept the CGC label as a synonym for CNPJ.
  • Records from the Departamento de Policia Federal (DPF): dispatches and authorizations issued before 1998 in archives of SP, PR and RS still reference parties by CGC-MF.
  • Receita Federal historical exports: some bulk dumps of the corporate registry preserve the historical CGC label in column names for backward compatibility.

Anti-patterns and the upcoming CNPJ alfanumerico

A common bug in integration code is to treat the CGC label as an unknown document type and reject it outright. The correct behavior is to accept CGC as a synonym for CNPJ and apply the same validation. A second pitfall: some pre-1998 contracts list a CGC-MF prefix or a slash inside the base number โ€” these are purely typographical conventions and disappear once you keep only the 14 digits.

From July 2026, the Receita Federal will issue new CNPJ numbers in alphanumeric format (digits in the first 12 positions can be letters). The 14-character total length and the modulo 11 algorithm stay the same โ€” letters convert to ASCII values minus 48 for the check-digit math. Existing CGC and numeric CNPJ records remain valid forever. The new format affects only new corporate registrations once the existing numeric range is exhausted.

FAQ

Is a CGC valid as a CNPJ today? Yes. The number, format and algorithm are the same. A 1995 CGC printed on a public-sector contract validates as a CNPJ in 2026.

Is the CGC label still used officially? No. Since 1998 the official label is CNPJ. The CGC label persists only in legacy systems, historical documents and informal references.

When did the change to CNPJ happen? In 1998 via Instrucao Normativa SRF 27/1998. The Receita Federal rolled out the rename across federal databases over 1998 and 1999, with state and municipal systems catching up across the early 2000s.

What about CGC-MF? The original full name was Cadastro Geral de Contribuintes do Ministerio da Fazenda. CGC-MF appears on documents from the Federal Police, Receita and SEFAZs from the 1980s and 1990s. Same number, same validation.

Should I migrate database columns from CGC to CNPJ? Yes when you control the system. Keep the underlying VARCHAR(14) or CHAR(14) storage, rename the column and update the UI label. Avoid breaking integrations that still post payloads with a cgc key โ€” accept both keys on input and normalize to cnpj internally.

Related Tools