National NFS-e Access Key Validator
Validate structural authenticity, issuing municipality, federal tax ID, and Modulo 11 check digit of 50-digit Brazilian National NFS-e keys.
About National NFS-e Validation
Validation inspects the 50-digit sequence (or 53 digits if prefixed with 'NFS'), municipal IBGE code, CPF or CNPJ structural legitimacy, and Modulo 11 check digit precision.
Access key inconsistencies cause tax rejection in corporate ERPs and municipal tax gateways (Sefin).
Anatomy & Structure of National NFS-e Key (50 Digits)
Official structure standardized by the National NFS-e Taxpayer Manual (MOC):
| Position | Field | Length | Meaning & Specification | Example |
|---|---|---|---|---|
| 01 to 07 | cMun | 7 digits | IBGE code of the municipality where ISS tax applies | 3550308 (SP) |
| 08 | tpAmb | 1 digit | Issuing environment (1=Municipal System, 2=National) | 2 |
| 09 | tpInsc | 1 digit | Issuer ID type (1=CPF, 2=CNPJ) | 2 |
| 10 to 23 | Insc | 14 characters | Federal Tax ID (CPF with 3 leading zeros or CNPJ) | 00000000000191 |
| 24 to 36 | nNFSe | 13 digits | NFS-e sequential invoice number in National Environment | 0000000000001 |
| 37 to 40 | AAMM | 4 digits | Year and month of document issuance | 2609 |
| 41 to 49 | cNFSe | 9 digits | Random numerical security code | 123456789 |
| 50 | cDV | 1 digit | Check digit calculated via Modulo 11 | 0 |
Check Digit Calculation Algorithm (Modulo 11)
Official calculation performed by tax authorities on the first 49 positions:
S = Σ(d_i * weight_i) | DV = rem < 2 ? 0 : 11 - rem
- 1. Iterate from position 49 down to 1 (from right to left).
- 2. Convert characters to numeric values (ASCII - 48).
- 3. Multiply each value by cyclic weights [2, 3, 4, 5, 6, 7, 8, 9, 2, 3...].
- 4. Sum all products and calculate the remainder modulo 11 (Sum % 11).
- 5. If remainder is 0 or 1, check digit is 0; otherwise it is 11 minus remainder.