A .NET Core library to calculate and validate the Italian Tax Code (Codice Fiscale)
The CodiceFiscale library provides an easy-to-use interface for generating and validating the Italian Tax Code based on personal data such as name, surname, date of birth, and city of birth.
It is designed for .NET developers who need to work with the Italian Tax Code in applications like tax management, user registration, and government service integrations.
You can install the CodiceFiscale library via NuGet Package Manager:
dotnet add package CodiceFiscale --version X.X.X
Or by adding the following to your .csproj:
<PackageReference Include="CodiceFiscale" Version="X.X.X" />
Once installed, restore the packages:
dotnet restore
Here’s a few examples of how to use the library:
using CodiceFiscaleLib.Helpers;
string result =
.Encode("Rossi", "Mario", 'M', new DateTime (1980, 5, 20), "Milano");
Console.WriteLine($"Generated Codice Fiscale: {result}");
using CodiceFiscaleLib.Helpers;
// decode
var decoded = DecodingHelper.Decode(code);
// get the dictionary
var decodedDict = (Dictionary<string, string>)decoded["raw"];
// access the value
string firstName = decodedDict["firstname"];
Console.WriteLine($"Decoded Codice Fiscale First Name: {firstName}");
using CodiceFiscaleLib.Helpers;
bool isValid = DecodingHelper.IsValid("RSSMRA80E20F205I");
Console.WriteLine($"Is valid Codice Fiscale: {isValid}");
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository
- Create a new branch (git checkout -b feature/your-feature)
- Commit your changes (git commit -am 'Add new feature')
- Push the branch (git push origin feature/your-feature)
- Open a Pull Request
Please ensure all pull requests pass the existing tests and include new tests for any added functionality
This project is licensed under the GPL-3.0 License. See the LICENSE file for more details
Special thanks to all contributors and resources that made this project possible