
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
@br-validators/core
Advanced tools
The Brazilian document validation library for TypeScript — CPF, CNPJ (alphanumeric), NF-e, PIX, boleto, IE (27 UFs), offline IBGE/ANP/NCM/CST/LC116 reference data, and 15+ more. Zero deps, fully typed, never throws.
The Brazilian document validation library for TypeScript.
Validate, format, and generate CPF, CNPJ (including the new alphanumeric format), NF-e, BR Code PIX, boleto, IE (all 27 states), EAN barcodes, CNIS/NIT, ANP fuel prices, and 20+ more — zero dependencies, fully typed, never throws.
npm install @br-validators/core
Try it now → doc-raiz-playground.vercel.app
CLI → npm install -g @br-validators/cli
⚠️ The unscoped
br-validatorson npm is a different package. Use@br-validators/core.
Every Brazilian SaaS eventually reinvents CPF validation — usually wrong.
@br-validators/core implements each algorithm from its official primary source
(Receita Federal, Bacen, CONTRAN, TSE, SEFAZ, FEBRABAN, Anatel) so you don't have to.
{ ok: true, value } | { ok: false, message, code }cMunFG), Bacen banks, DDD lookup, national holidays, CNAE, CFOP, CST, LC 116, NCM, IBPT tax burden, Simples Nacional, CBO, natureza jurídica, NBS, CEST, eSocial categorias, CNPJ motivos, moedas, PTAX cotações, países Bacen, NF-e cUF, IRPF / INSS tables, SELIC meta, ISS municipal (sample), Incoterms, portos, aeroportos, ANP fuel prices (LPC) — embedded offline with daily freshness (DATA-FRESHNESS.md; ANP weekly)import { validateCpf, formatCpf } from '@br-validators/core';
validateCpf('123.456.789-09');
// { ok: true, value: '12345678909' }
formatCpf('12345678909');
// { ok: true, formatted: '123.456.789-09' }
validateCpf('111.111.111-11');
// { ok: false, message: 'CPF with all identical digits is invalid', code: 'KNOWN_INVALID_PATTERN' }
import { validateCnpj, formatCnpj } from '@br-validators/core/cnpj';
// Numeric (current format)
validateCnpj('11.222.333/0001-81');
// { ok: true, value: '11222333000181', format: 'numeric' }
// Alphanumeric (new format — effective July 2026)
validateCnpj('12ABC34501DE35');
// { ok: true, value: '12ABC34501DE35', format: 'alphanumeric' }
formatCnpj('12ABC34501DE35');
// { ok: true, formatted: '12.ABC.345/01DE-35' }
import { detect } from '@br-validators/core';
detect('123.456.789-09');
// { type: 'cpf', ok: true, value: '12345678909' }
detect('ABC1D23');
// { type: 'placa', ok: true, format: 'mercosul' }
detect('110042490114', { uf: 'SP' });
// { type: 'inscricao-estadual', ok: true }
import { generate } from '@br-validators/core';
generate('cpf', { seed: 42 }); // reproducible, always valid
generate('cnpj', { format: 'alphanumeric', masked: true });
generate('placa', { format: 'mercosul' });
generate('renavam');
generate('cnh');
generate('inscricao-estadual', { uf: 'SP', seed: 42 });
generate('titulo-eleitor', { uf: 'SC', seed: 42 });
generate('cartao-credito', { brand: 'visa', seed: 42 });
generate('pix', { seed: 42 }); // EVP UUID — Bacen DICT
generate('nfe-chave', { seed: 42 }); // MOC §2.2.6 modulo-11 DV
generate('brcode', { seed: 42 }); // static PIX EMV + CRC16
generate('boleto', { masked: true }); // FEBRABAN cobrança Situação 1
generate('boleto-arrecadacao'); // FEBRABAN Layout v7
generate('inscricao-estadual-produtor-rural', { masked: true }); // SP SINTEGRA Bloco II
generate()is for test fixtures and seed data only — never use in production.
Alphanumeric CPF:generate('cpf', { format: 'alphanumeric' })throwsCPF_ALPHA_SPEC_PENDINGuntil RFB publishes the official algorithm (OFFICIAL-SOURCES.md).
import { sanitize } from '@br-validators/core';
sanitize(' 123.456.789-09 ', 'cpf');
// { ok: true, value: '12345678909', fixes: ['trimmed', 'removed_non_digits'] }
sanitize('110.042.490.114', 'inscricao-estadual', { uf: 'SP' });
// { ok: true, value: '110042490114', fixes: [...] }
import { validateNfeChave, parseNfeChave } from '@br-validators/core/nfe-chave';
const result = validateNfeChave('52060433009911002506550120000007800267301615');
// { ok: true, parsed: { cUF: '52', cnpj: '33009911002506', mod: '55', ... }, uf: 'GO' }
import {
buildStaticPixBrCode,
parseBrCode,
validateBrCode,
} from '@br-validators/core/brcode';
// Permanent static QR (no amount — payer sets value at payment time)
const payload = buildStaticPixBrCode({
pixKey: 'pix@bcb.gov.br',
merchantName: 'Fulano de Tal',
merchantCity: 'BRASILIA',
});
validateBrCode(payload).ok; // true
// Fixed-value static QR
buildStaticPixBrCode({
pixKey: 'pix@bcb.gov.br',
merchantName: 'Fulano de Tal',
merchantCity: 'BRASILIA',
amount: '10.50',
});
parseBrCode(payload);
// { ok: true, pixKey, pixKeyType, merchantName, merchantCity, amount, txid }
Playground: doc-raiz-playground.vercel.app/pix renders the QR image from buildStaticPixBrCode output. Official sources: Bacen Manual BR Code · Manual de Padrões PIX.
import { validateBoleto, validateArrecadacao } from '@br-validators/core/boleto';
validateBoleto('03399.02579 08991.834006 71742.301014 6 14500000099668');
// cobrança Situação 1/2 — FEBRABAN FB-0061/2021
validateArrecadacao('846300000003812345678906123456789015234567890129');
// arrecadação 48-digit — FEBRABAN Layout v7
import { mask, compare, batch, diff } from '@br-validators/core';
mask('12345678909', 'cpf');
// { ok: true, formatted: '123.456.789-09' }
compare('123.456.789-09', '12345678909', 'cpf');
// { equal: true }
batch(['12345678909', 'invalid'], 'cpf');
// { valid: [...], invalid: [...], summary: { total: 2, valid: 1, invalid: 1 } }
diff('12345678909', '12345678901', 'cpf');
// { changed: true, fields: [{ field: 'dv', a: '09', b: '01' }] }
import { validateNcm } from '@br-validators/core/ncm';
import { validateCfop } from '@br-validators/core/cfop';
import { validateCst } from '@br-validators/core/cst';
import { lookupNcmPorCodigo } from '@br-validators/core/ncm';
validateNcm('01012100'); // { ok: true, value: '01012100', row: { ... } }
validateCfop('1102'); // dotted or plain CONFAZ codes
validateCst('00', { tax: 'icms' });
lookupNcmPorCodigo('01012100'); // LookupResult — ok / not-found / invalid-format
Per-type rules and official sources: docs/OFFICIAL-SOURCES.md · API contract: docs/LIBRARY-API.md
Backend / form integration:
format*andmask()validate first — they never left-pad partial input ("0"will not become000.000.000-00). Do not combinepadStartwith display formatting inonChange; pad to full width only at submit if your API requires it. Details: LIBRARY-API.md — display vs backend normalization.
'use client';
import { validateCnpj, formatCnpj } from '@br-validators/core/cnpj';
import { useState } from 'react';
export function CnpjField() {
const [input, setInput] = useState('');
const result = input ? validateCnpj(input) : null;
const formatted = result?.ok ? formatCnpj(result.value) : null;
return (
<div>
<input value={input} onChange={e => setInput(e.target.value)} />
{formatted?.ok && <p>✅ {formatted.formatted}</p>}
{result && !result.ok && <p>❌ {result.message}</p>}
</div>
);
}
br-validators cnpj validate "$CNPJ" --quiet || exit 1
br-validators ie validate "$IE" --uf SP --json
br-validators detect '123.456.789-09' --json
br-validators generate cpf --seed 42 --masked
br-validators generate pix --seed 42
br-validators generate nfe-chave --seed 42
br-validators generate brcode --seed 42
br-validators generate boleto --masked --seed 42
br-validators generate boleto-arrecadacao --seed 42
br-validators generate inscricao-estadual-produtor-rural --masked --seed 42
| Document | Subpath import | CLI | Playground |
|---|---|---|---|
| CPF | @br-validators/core/cpf | br-validators cpf … | /cpf |
| CNPJ (numeric + alphanumeric) | @br-validators/core/cnpj | br-validators cnpj … | /cnpj |
| CEP | @br-validators/core/cep | br-validators cep … | /cep (+ getCepFaixaInfo prefix lookup) |
| Telefone | @br-validators/core/telefone | br-validators telefone … | /telefone |
| CNH | @br-validators/core/cnh | br-validators cnh … | /cnh |
| RENAVAM | @br-validators/core/renavam | br-validators renavam … | /renavam |
| Título de Eleitor | @br-validators/core/titulo-eleitor | br-validators titulo-eleitor … | /titulo-eleitor |
| Processo judicial CNJ | @br-validators/core/processo-judicial | br-validators processo-judicial … | /processo-judicial |
| RG (27 UFs — identity card) | @br-validators/core/rg | br-validators rg … --uf SP | /rg |
| Placa (Mercosul + legada) | @br-validators/core/placa | br-validators placa … | /placa |
| PIS / PASEP / NIS | @br-validators/core/pis-pasep | br-validators pis-pasep … | /pis |
| CNIS / NIT (worker ID) | @br-validators/core/cnis | br-validators cnis … | /cnis |
| EAN-8 / EAN-13 (barcode) | @br-validators/core/ean | br-validators ean … | /ean |
| PIX key | @br-validators/core/pix | br-validators pix … | /pix |
| BR Code (PIX QR payload + builder) | @br-validators/core/brcode | br-validators brcode … | /brcode |
| Boleto cobrança (Situação 1 + 2) | @br-validators/core/boleto | br-validators boleto … | /boleto |
| Boleto arrecadação (48/44) | @br-validators/core/boleto | br-validators boleto … | /boleto |
| NF-e / NFC-e chave (44 digits) | @br-validators/core/nfe-chave | br-validators nfe-chave … | /nfe-chave |
| Cartão de crédito (Luhn) | @br-validators/core/cartao-credito | br-validators cartao … | /cartao-credito |
| Inscrição Estadual (27 UFs) | @br-validators/core/inscricao-estadual | br-validators ie … --uf SP | /ie |
| IE Produtor Rural | @br-validators/core/inscricao-estadual-produtor-rural | br-validators ie … (auto P) | /ie |
| detect() | @br-validators/core/detect | br-validators detect … | /detect |
| sanitize() | @br-validators/core/sanitize | br-validators sanitize … | /sanitize |
| mask() | @br-validators/core/mask | br-validators mask … | via per-type format |
| compare() | @br-validators/core/compare | br-validators compare … | /compare |
| batch() | @br-validators/core/batch | br-validators batch … | /batch |
| diff() | @br-validators/core/diff | br-validators diff … | /diff |
| generate() | @br-validators/core/generate | br-validators generate … | /generate |
| buildStaticPixBrCode() | @br-validators/core/brcode | — | /pix (QR panel) |
Embedded JSON from official .gov.br sources — no runtime HTTP. Each module exports *_DATA_VERSION with capture date, row counts, and source URLs. Aggregated via @br-validators/core/data-catalog.
| Dataset | Subpath | CLI | Playground | Key APIs | Official source |
|---|---|---|---|---|---|
| IBGE states + municipalities + NF-e cMunFG | @br-validators/core/ibge | ibge lookup · list | /data/ibge | getEstados, getMunicipios, getMunicipioPorCodigo, toCmunFg, parseCmunFg | IBGE localidades API |
| Bacen STR banks (COMPE / ISPB) | @br-validators/core/bancos | bancos lookup · list | /data/bancos | getBancos, getBancoPorCodigo, getBancoPorIspb | Bacen Participantes STR |
| ANAC public aerodromos | @br-validators/core/aeroportos | aeroportos lookup | /data/logistics | getAeroportos, getAeroportoPorIata, getAeroportoPorIcao, getAeroportosPorMunicipio | ANAC aeródromos públicos CSV |
| ANTAQ port installations | @br-validators/core/portos | portos lookup | /data/logistics | getPortoPorCodigo, searchPortos, getPortosPorMunicipio | ANTAQ instalações portuárias zip |
| ANP fuel prices (LPC) | @br-validators/core/anp-combustiveis | — | /data/logistics | getAnpPrecosMedios, getAnpPrecosMediosPorIbge, getAnpSemanaAtual | ANP levantamento LPC |
| TSE ↔ IBGE municipality codes | @br-validators/core/tse-municipios | tse-municipios lookup | /data/ibge (cross-ref) | getMapeamentoTseIbge, getMunicipioIbgePorCodigoTse, getCodigosTsePorMunicipio | TSE municipio_tse_ibge.zip |
| DDD geographic lookup | @br-validators/core/telefone | ddd lookup | — | getDddInfo (extends telefone validator) | Anatel DDD panel |
| National holidays | @br-validators/core/feriados | feriados list --year | /data/calendar | isFeriadoNacional, getFeriadosNacionais, getProximoDiaUtil | Lei 662/1949 + annual Portaria MGI |
| CNAE 2.3 subclasses | @br-validators/core/cnaes | cnae lookup · search | /data/fiscal | getCnaePorCodigo, searchCnaes | IBGE CNAE API v2 |
| CFOP fiscal operations | @br-validators/core/cfop | cfop lookup · search | /data/fiscal | getCfopPorCodigo, searchCfop | CONFAZ CFOP SINIEF |
| CST (ICMS, IPI, PIS, COFINS) | @br-validators/core/cst | — | /data/fiscal | getCstIcmsPorCodigo, getCstIpiPorCodigo, searchCstIcms | RFB SPED CST tables |
| LC 116 ISS services | @br-validators/core/lc116 | — | /data/fiscal | getLc116PorCodigo, searchLc116 | LC 116/2003 Planalto |
| eSocial worker categories | @br-validators/core/esocial | — | /data/fiscal | getEsocialCategoriaPorCodigo, searchEsocialCategorias | eSocial S-1.3 Tabelas |
| NCM Mercosur nomenclature | @br-validators/core/ncm | ncm lookup · search | /data/fiscal | getNcmPorCodigo, searchNcm | Siscomex NCM JSON |
| IBPT approximate NCM tax burden | @br-validators/core/ibpt | — | /data/fiscal | getIbptCargaPorNcmUf, computeIbptCargaTotal | IBPT Lei 12.741/2012 |
| Simples Nacional annex tables | @br-validators/core/simples-nacional | — | /data/fiscal | getSimplesAnexo, getSimplesFaixa, computeSimplesAliquotaEfetiva | LC 123/2006 Planalto |
| CNPJ motivos situação cadastral | @br-validators/core/cnpj-motivos | — | /data/fiscal | getMotivosSituacaoCadastral, getMotivoSituacaoCadastralPorCodigo | RFB Motivos.zip |
| Natureza jurídica (CNPJ) | @br-validators/core/natureza-juridica | natureza-juridica lookup | /data/fiscal | getNaturezaJuridicaPorCodigo | RFB Naturezas.zip |
| NBS (NFSe Nacional) | @br-validators/core/nbs | nbs lookup | /data/fiscal | getNbsPorCodigo, searchNbs | NFSe Anexo B NBS2 xlsx |
| CEST (substituição tributária) | @br-validators/core/cest | cest lookup | /data/fiscal | getCestPorCodigo, getCestPorNcm, searchCest | CONFAZ ICMS 142/2018 |
| ISO 4217 + Bacen PTAX moedas | @br-validators/core/moedas | moedas lookup | /data/trade | getMoedaPorCodigo, searchMoedas | Bacen PTAX Moedas API |
| Bacen PTAX Fechamento | @br-validators/core/ptax | — | /data/trade | getPtaxCotacao, getPtaxUltimoDiaUtil | Bacen Olinda PTAX API |
| NF-e Bacen country codes | @br-validators/core/paises-bacen | paises-bacen lookup | /data/trade | getPaisPorCodigoBacen, getPaisesBacen | NF-e country table |
| NF-e cUF (IBGE state codes) | @br-validators/core/nfe-cuf | nfe-cuf lookup | /data/fiscal | getCufPorCodigo, lookupCufPorCodigo | NF-e cUF table |
| IRPF progressive brackets | @br-validators/core/irpf | irpf tabela · irpf calc | /data/payroll | getIrpfTabelaProgressiva, calcularIrpfMensal | RFB IRPF tables |
| INSS contribution brackets | @br-validators/core/inss | inss tabela · inss calc | /data/payroll | getInssTabelaContribuicao, calcularInssMensal | INSS contribution rates |
| Bacen SELIC meta | @br-validators/core/selic | selic | /data/finance | getSelicMeta, getSelicMetaPorData | Bacen SGS série 432 |
| ISS municipal rates (sample) | @br-validators/core/iss-municipal | iss-municipal lookup · search | /data/fiscal | getIssMunicipalPorIbge, searchIssMunicipal | IBGE PIB municipal 2022 |
| ICC Incoterms 2020 | @br-validators/core/incoterms | incoterms lookup | /data/trade | getIncotermPorCodigo, getIncoterms | ICC Incoterms rules |
| CBO 2002 occupations | @br-validators/core/cbo | cbo lookup · search | /data/fiscal | getCboPorCodigo, searchCbo | MTE CBO downloads |
| CEP prefix lookup | @br-validators/core/cep | cep faixa | — | getCepFaixaInfo, getCepFaixas | IBGE CNEFE 2022 |
| Data transparency catalog | @br-validators/core/data-catalog | — | /data/catalog | getDataCatalog, getDatasetMetadata | Aggregates all metadata.json entries |
import { getMunicipioPorCodigo } from '@br-validators/core/ibge';
import { getBancoPorCodigo } from '@br-validators/core/bancos';
import { getDddInfo } from '@br-validators/core/telefone';
import { isFeriadoNacional } from '@br-validators/core/feriados';
import { getCnaePorCodigo } from '@br-validators/core/cnaes';
import { getCfopPorCodigo } from '@br-validators/core/cfop';
import { getCstIcmsPorCodigo } from '@br-validators/core/cst';
import { getLc116PorCodigo } from '@br-validators/core/lc116';
import { getNcmPorCodigo } from '@br-validators/core/ncm';
import { getCboPorCodigo } from '@br-validators/core/cbo';
import { getNaturezaJuridicaPorCodigo } from '@br-validators/core/natureza-juridica';
import { getNbsPorCodigo } from '@br-validators/core/nbs';
import { getCestPorCodigo } from '@br-validators/core/cest';
import { getMoedaPorCodigo } from '@br-validators/core/moedas';
import { getPaisPorCodigoBacen } from '@br-validators/core/paises-bacen';
import { getIncotermPorCodigo } from '@br-validators/core/incoterms';
import { getAeroportoPorIata } from '@br-validators/core/aeroportos';
import { getPortoPorCodigo } from '@br-validators/core/portos';
import { getAnpPrecosMedios } from '@br-validators/core/anp-combustiveis';
import { getSelicMeta } from '@br-validators/core/selic';
import { getIrpfTabelaProgressiva } from '@br-validators/core/irpf';
import { getInssTabelaContribuicao } from '@br-validators/core/inss';
import { getCufPorCodigo } from '@br-validators/core/nfe-cuf';
import { getIssMunicipalPorIbge } from '@br-validators/core/iss-municipal';
import { getDataCatalog } from '@br-validators/core/data-catalog';
getMunicipioPorCodigo(3550308)?.nome; // São Paulo
getBancoPorCodigo('001')?.nome; // Banco do Brasil
getDddInfo('11')?.uf; // SP
isFeriadoNacional('2026-01-01'); // true — Confraternização Universal
getCnaePorCodigo('6201501'); // custom software development
getCfopPorCodigo('1.102'); // accepts CONFAZ dotted format
getNcmPorCodigo('01012100'); // purebred horses (8-digit leaf)
getCboPorCodigo('212405'); // systems development analyst
getNaturezaJuridicaPorCodigo('2062'); // Sociedade Empresária Limitada
getNbsPorCodigo('1.1502.50.00'); // TI systems integration (NFSe)
getCestPorCodigo('0302100'); // returnable beer bottle (ST)
getMoedaPorCodigo('BRL')?.nome; // Real Brasileiro
getPaisPorCodigoBacen('1058')?.nome; // Brasil (NF-e cPais)
getIncotermPorCodigo('FOB')?.nome; // Free On Board
getAeroportoPorIata('GRU')?.nome; // Guarulhos — SP
getPortoPorCodigo('BRSSZ')?.nome; // Santos organized port
getAnpPrecosMedios({ uf: 'SP', municipio: 'São Paulo', produto: 'GASOLINE_REGULAR' })?.precoMedio;
getSelicMeta()?.valor; // latest Bacen SELIC meta (% a.a.)
getIrpfTabelaProgressiva(2026); // progressive monthly brackets
getInssTabelaContribuicao(2026); // INSS contribution table
getCufPorCodigo('35')?.uf; // SP (NF-e cUF)
getIssMunicipalPorIbge(3550308); // São Paulo ISS sample row
getDataCatalog().length; // registered datasets
Freshness table (auto-updated daily; ANP weekly): docs/DATA-FRESHNESS.md · Per-type official URLs: docs/OFFICIAL-SOURCES.md
v1.9.0 — Phase 33 maturity: LookupResult API, fiscal validators, IRPF / INSS / SELIC / ISS municipal / NF-e cUF datasets, platform CLI (compare / batch / diff / mask), RG 27/27 UFs, MIGRATION.md, TypeDoc API reference. CHANGELOG
// Only ships the CPF module — nothing else
import { validateCpf } from '@br-validators/core/cpf';
// Only ships NF-e module
import { parseNfeChave } from '@br-validators/core/nfe-chave';
| Package | npm |
|---|---|
@br-validators/cli | Terminal — validate, format, detect, generate |
@br-validators/zod | Zod 3/4 schemas |
@br-validators/react-hook-form | RHF rules + resolvers |
@br-validators/express | Express + Fastify middleware |
@br-validators/vue | Vue 3 composables |
Issues, corrections, and new document types are welcome.
See CONTRIBUTING.md and open good first issue items.
MIT — permanently free and open source.
FAQs
The Brazilian document validation library for TypeScript — CPF, CNPJ (alphanumeric), NF-e, PIX, boleto, IE (27 UFs), offline IBGE/ANP/NCM/CST/LC116 reference data, and 15+ more. Zero deps, fully typed, never throws.
The npm package @br-validators/core receives a total of 2,706 weekly downloads. As such, @br-validators/core popularity was classified as popular.
We found that @br-validators/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.