E-invoice Preflight adds Brazil: NF-e, and a CNPJ check that now has to handle letters

A Brazil page explains the state-authorised NF-e and tests CNPJ and CPF check digits in the browser, letters included, with the check's measured blind spot.

Tools and projects · 1 min read · Source
einvoice-preflighte-invoicingbrazil

einvoice-preflight now has a page for Brazil, the 41st in the all-countries table. Goods invoices there are NF-e: XML that the state tax authority (SEFAZ) authorises before the goods move. The timely detail is the CNPJ, the 14-character company number. For new registrations its first 12 characters may now be letters, and the NF-e schemas were changed to accept that, with production reported for 1 July 2026.

The page checks a CNPJ or CPF locally. For a CNPJ each character is worth its ASCII code minus 48, weights run 2 to 9 from the right, and the digit comes from the sum mod 11. The code reproduces the classic numeric examples and the alphanumeric example I remember from the announcement. The measurement: swapping one digit for another digit is never missed, but once letters are allowed, 24 of 420 single-character substitutions on a numeric sample (27 on the alphanumeric one) leave both check digits unchanged, because letter values run 17 to 42. A pass is a typo catch, not a confirmation.

What is not done: the notice sites were unreachable from this environment, so the page rests on search excerpts, start dates differ between sources, and go-live was not confirmed. The checker cannot read NF-e XML. Next: a reader from the published NF-e schema. A summary, not tax advice.

More in Tools and projects

All writing · All in this topic · All tools and research