ItalianFiscalKit 2.0.0

dotnet add package ItalianFiscalKit --version 2.0.0
                    
NuGet\Install-Package ItalianFiscalKit -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ItalianFiscalKit" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ItalianFiscalKit" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ItalianFiscalKit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ItalianFiscalKit --version 2.0.0
                    
#r "nuget: ItalianFiscalKit, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ItalianFiscalKit@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ItalianFiscalKit&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ItalianFiscalKit&version=2.0.0
                    
Install as a Cake Tool

<p align="center"> <img src="assets/icon.svg" alt="ItalianFiscalKit icon" width="96" /> </p>

ItalianFiscalKit

Build Coverage Downloads

FULL DOCUMENTATION: https://dennisturco.github.io/ItalianFiscalKit/

A lightweight .NET library for Italian fiscal compliance: validate, parse and generate Fiscal Code, validate Partita IVA and IBAN, and query a built-in database of Italian municipalities and foreign countries (Belfiore codes). Everything runs locally, no HTTP calls, no data leaves your app.

NuGet License: MIT

Installation

dotnet add package ItalianFiscalKit

Features

  • Fiscal code validation (format + checksum)
  • Fiscal code generation from personal data
  • Cross-check: does this fiscal code match these personal details?
  • Italian VAT number validation (standard, public entity, foreign)
  • IBAN validation (mod97, all countries)
  • Comuni and codici Belfiore embedded dataset (no external files needed)
  • Fully tested

Usage

  1. Validate a fiscal code

    using ItalianFiscalKit;
    
    bool isValid = FiscalCodeValidator.IsValid("RSSMRA80A01H501U"); // true
    
  2. Generate a fiscal code

    string cf = FiscalCodeGenerator.Generate(
        name:        "Mario",
        surname:     "Rossi",
        dateOfBirth: new DateOnly(1980, 1, 1),
        gender:      Gender.Male,
        belfioreCode: "H501"   // Roma — use MunicipalityExtensions to look up the code
    ); // "RSSMRA80A01H501U"
    
  3. Cross-check fiscal code against personal data

    bool matches = FiscalCodeMatcher.Matches(
        cf:           "RSSMRA80A01H501U",
        name:         "Mario",
        surname:      "Rossi",
        dateOfBirth:  new DateOnly(1980, 1, 1),
        gender:       Gender.Male,
        belfioreCode: "H501"
    ); // true
    
  4. Parse a fiscal code

    FiscalCodeData parsed = FiscalCodeParser.Parse("RSSMRA80A01H501U");
    
    parsed.Gender       // Male
    parsed.DateOfBirth  // 1980-01-01
    parsed.BelfioreCode // "H501"
    
  5. Age helpers (extension methods on FiscalCodeData)

    int age     = parsed.GetAge();    // e.g. 45
    bool adult  = parsed.IsAdult();   // true if age >= 18
    
  6. Look up a municipality

    Municipality? comune = "H501".GetMunicipalityByBelfiore(); // Roma
    Municipality? byName = "Milano".GetMunicipalityByName();
    Municipality? byCAP  = "00186".GetMunicipalityByCAP();
    
    IEnumerable<Municipality>? inRoma = "Roma".GetAllByProvince(); // 121 comuni
    IEnumerable<Municipality>  all    = MunicipalityExtensions.GetAll(); // ~7 896
    
  7. Validate an Italian VAT number

    bool isValid = ItalianVatCodeValidator.IsValid("00484960588", isConsumer: false, isFiscal: false); // true
    
  8. Validate an IBAN

    bool isValid = IBANValidator.IsValid("IT60X0542811101000000123456"); // true
    

Edge cases handled

  • Names with fewer than 3 consonants (Re, Li, Yu)
  • Names with apostrophes and accents (D'Amico, Rosà)
  • Foreign-born individuals (Belfiore code Z + country number)
  • Omocodia (alternate fiscal codes with letters replacing digits)
  • VAT numbers for public entities (starting with 8 or 9)
  • Obsolete municipalities (comuni soppressi)

Why not an API?

Fiscal codes and VAT numbers are personal data. Sending them to a third-party server to validate them raises immediate GDPR concerns. This library validates everything locally. The data never leaves your application.

Dataset

The comuni/Belfiore dataset is sourced from ISTAT open data and embedded directly in the library binary. No external files are required at runtime.

The dataset is updated with each minor release to reflect municipality changes (merges, renames, new comuni).

Contributing

Contributions are welcome. If you find a fiscal code that validates incorrectly, please open an issue with:

  1. The fiscal code (you can anonymise it — just keep the structure)
  2. The personal data it should/should not match
  3. The expected result

License

License: MIT

Municipalities data

https://comuni-ita.readme.io/reference/getcomuni

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 38 6/3/2026