python-codicefiscale
encode / decode italian fiscal codes - codifica / decodifica del Codice Fiscale italiano.
What it is and what it does
python-codicefiscale is a library for encoding and decoding Italian fiscal codes (Codice Fiscale), the unique personal tax identifier used in Italy. It takes personal information—name, surname, gender, birthdate, and birthplace—and generates the corresponding fiscal code, or reverses the process to extract demographic data from an existing code. The library handles multiple birthdate formats, automatically detects Italian city and foreign country codes, and supports omocodia (alternative valid representations of the same code).
The package includes both a Python API and a command-line interface. It depends on python-dateutil for date handling, python-fsutil for file operations, and python-slugify for text normalization. Data is auto-updated weekly from ANPR (the Italian national registry), and the library can suggest possible first names from encoded codes—achieving near-certain identification in approximately 60% of Italian cases. It is actively maintained, supports Python 3.10 through 3.14, and carries no known security vulnerabilities.
Use it for:
- Generate fiscal codes for Italian citizens during user registration or identity verification workflows
- Validate or decode existing fiscal codes to extract and verify demographic information
- Batch-process fiscal codes in administrative or tax-related applications
- Integrate fiscal code handling into Italian e-government or compliance systems
- Resolve ambiguous name encodings by retrieving possible first-name candidates from a code
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Encodes and decodes Italian fiscal codes (Codice Fiscale), with support for validation, omocodia detection, and automatic birthplace lookup from Italian and foreign locations.
Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed under MIT. Install it if you need to work with Italian fiscal codes in Python—whether for encoding, decoding, validation, or integration into Italian administrative systems.
Install
python-codicefiscale on PyPI
pip
pip install python-codicefiscaleuv
uv add python-codicefiscalepoetry
poetry add python-codicefiscaleInstalling python-codicefiscale
Before you install
Low friction install with three lightweight runtime dependencies (python-dateutil, python-fsutil, python-slugify). Active maintenance with a recent release and ongoing repository activity.
License in practice
MIT License permits unrestricted use, modification, and distribution with minimal restrictions—suitable for commercial and open-source projects alike.
Quickstart
pip install python-codicefiscale
from codicefiscale import codicefiscale
# Encode
code = codicefiscale.encode(
lastname="Caccamo",
firstname="Fabio",
gender="M",
birthdate="03/04/1985",
birthplace="Torino"
)
# Decode
result = codicefiscale.decode(code)
# Validate
is_valid = codicefiscale.is_valid(code)
Verify before relying
- Whether ANPR data updates occur reliably once per week as described
- Accuracy of the ~60% single-name-match rate for Italian birthplaces in real-world use
- Performance characteristics when processing large batches of codes
Package facts
| License | MIT License Copyright (c) 2017-present Fabio Caccamo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),… (full text in the JSON record) (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — python-dateutil, python-fsutil, python-slugify |
| Maintenance | actively maintained — 98 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 102,908/month — #12,837 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_codicefiscale-0.12.1-py3-none-any.whl
Keywords: codicefiscale, codice, fiscale, cf, fiscal code, italia, italy
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
python-stdnumParses, validates, and reformats standard…
copyleft · top 5,000 on PyPI
BrazilFiscalReportConverts Brazilian electronic invoice XML files…
agpl · top 15,000 on PyPI
sqidsSqids encodes numbers into short, unique,…
permissive · top 15,000 on PyPI
fiscalyearProvides fiscal year, quarter, month, and day…
permissive · top 15,000 on PyPI
sed4onnxEncodes and decodes Base64-formatted constant…
permissive · top 15,000 on PyPI
ecojiEncodes and decodes binary data as sequences of…
permissive · top 15,000 on PyPI
rf-protocolsDecodes and encodes radio frequency signals for…
permissive · top 15,000 on PyPI
hdx-python-countryMaps country and region codes and names,…
permissive · top 15,000 on PyPI
bencode.pyEncodes and decodes bencode format, the binary…
unclear · top 15,000 on PyPI
ebcdicRegisters additional EBCDIC character encoding…
permissive · top 5,000 on PyPI