Free · No sign-up · Nothing is sent
Check a Spanish company NIF (CIF)
Type the letter and 7 digits to calculate the control character, or all 9 characters to check it.
A matching control character only rules out typos. Whether the company exists or is active is known only to the Tax Agency.
Type the letter and 7 digits to calculate the control character, or the full number to see whether it matches. It tells you the entity type from the first letter and how to check with the Spanish Tax Agency whether the company is active.
Runs in your browser. The number you type is never sent or stored.
What it checks
What this tool checks (and what it does not)
- Yes: the shape of an entity NIF (one letter, 7 digits and a control character), the entity type from the letter, and whether the last character matches the commonly used calculation.
- Yes, but indicative: the control character. No regulation publishes how it is calculated, so if it does not match we flag it, but we never call the number invalid.
- No: whether the company exists, has been deregistered or revoked, or its name. Only the Spanish Tax Agency (AEAT) knows that.
Is it an individual's number (DNI, NIE or a K, L or M NIF)? The tool detects it and sends you to the DNI and NIE validator.
Is it active?
How to check whether a company NIF is active
The AEAT service «Comprobación de un NIF de terceros a efectos censales» checks numbers against the tax census. You need Cl@ve Móvil, a digital certificate or an electronic DNI. It accepts one NIF, a list or a CSV file of up to 20,000 records.
| Answer | Meaning |
|---|---|
| IDENTIFICADO | The NIF exists. Returns the current NIF and company name. |
| NO IDENTIFICADO | No taxpayer matches that NIF. |
| IDENTIFICADO-BAJA | It exists but has been deregistered. |
| IDENTIFICADO-REVOCADO | It exists but the NIF has been revoked. |
Letters
What the first letter of a company NIF means
The first letter is set by law: Order EHA/451/2008 assigns it by legal form (art. 3), foreign entity (art. 4) or permanent establishment (art. 5):
| Letter | Entity type | Art. | Usual control |
|---|---|---|---|
| A | Public limited companies (sociedad anónima, S.A.) | 3 | Digit |
| B | Private limited companies (sociedad limitada, S.L.) | 3 | Digit |
| C | General partnerships | 3 | Digit or letter |
| D | Limited partnerships | 3 | Digit or letter |
| E | Joint ownerships, undistributed estates and other entities without legal personality not listed elsewhere | 3 | Digit |
| F | Cooperatives | 3 | Digit or letter |
| G | Associations | 3 | Digit or letter |
| H | Owners' associations of apartment buildings | 3 | Digit |
| J | Civil partnerships | 3 | Digit or letter |
| N | Foreign entities | 4 | Letter |
| P | Local authorities | 3 | Letter |
| Q | Public bodies | 3 | Letter |
| R | Religious congregations and institutions | 3 | Letter |
| S | Central and regional government bodies | 3 | Letter |
| U | Joint ventures (UTE) | 3 | Digit or letter |
| V | Other types not covered by the other letters | 3 | Digit or letter |
| W | Permanent establishments of non-resident entities | 5.2 | Letter |
CIF or NIF
Are CIF and NIF the same?
Yes. CIF is the old name of the company tax number, created by Decree 2423/1975. Royal Decree 1065/2007, in force since 1 January 2008, repealed it, and since then the law only speaks of the NIF for both individuals and entities. The format did not change: 9 characters.
How it works
How the control character is calculated (and why it is indicative)
No regulation publishes this calculation. Royal Decree 1065/2007 (art. 22) and Order EHA/451/2008 (art. 2) only say the NIF has «a control character». The method below is the commonly used one, and real numbers such as A28015865 (valid in VIES) match it, but without an official source we cannot claim it is the Tax Agency's.
- 101
Take the 7 digits
B1234567 → 1 2 3 4 5 6 7
The letter is not used.
- 202
Double odd positions, add their digits
2 + 6 + 1 + 5 = 14
Positions 1, 3, 5 and 7.
- 303
Add even positions
2 + 4 + 6 = 12
Positions 2, 4 and 6.
- 404
Complete to 10
26 → 6 → 10 − 6 = 4
B12345674. As a letter, 4 is D (0 = J, 1 = A … 9 = I).
No rule says which entities use a digit or a letter. The common convention is a letter for P, Q, R, S, N, W (and numbers starting with 00), a digit for A, B, E and H, and either for the rest. This tool accepts both.
Province
The first two digits no longer mean the province
Under the 1975 decree, two digits gave the province where the company was incorporated. Since July 2008, Order EHA/451/2008 uses «a random seven-digit number», so those digits mean nothing in newer numbers.
EU VAT
From NIF to EU VAT number
The EU VAT number of a Spanish company is ES + its NIF, but it is only active for intra-EU trade if the company is in the Register of Intra-Community Operators. Check it with our VIES validator.
Code
Company NIF control character in JavaScript and Python
Same calculation as this tool, with the same caveat: use it to flag likely typos, not to block a sign-up.
// Control character of a Spanish company NIF (formerly CIF).
// NOTE: this is the commonly used method; no regulation publishes it.
// Use it to flag likely typos, not to reject a number.
function companyNifControl(nif) {
const n = nif.toUpperCase().replace(/[\s.\-/]/g, "");
const m = /^([ABCDEFGHJNPQRSUVW])(\d{7})/.exec(n);
if (!m) return null;
let sum = 0;
[...m[2]].forEach((c, i) => {
const d = Number(c);
if (i % 2 === 0) {
const double = d * 2; // positions 1, 3, 5 and 7
sum += Math.floor(double / 10) + (double % 10);
} else {
sum += d; // positions 2, 4 and 6
}
});
const digit = (10 - (sum % 10)) % 10;
return { digit: String(digit), letter: "JABCDEFGHI"[digit] };
}
companyNifControl("B1234567"); // { digit: "4", letter: "D" }import re
LETTERS = "JABCDEFGHI"
def company_nif_control(nif: str):
"""Commonly used method; not published in any regulation."""
n = re.sub(r"[\s.\-/]", "", nif.upper())
m = re.match(r"^([ABCDEFGHJNPQRSUVW])(\d{7})", n)
if not m:
return None
total = 0
for i, c in enumerate(m.group(2)):
d = int(c)
if i % 2 == 0:
double = d * 2
total += double // 10 + double % 10
else:
total += d
digit = (10 - total % 10) % 10
return str(digit), LETTERS[digit]
company_nif_control("B1234567") # ("4", "D")FAQ
Spanish company NIF frequently asked questions
How do I know if a Spanish CIF is correct?
Check that it has an entity letter, 7 digits and a control character that matches the calculation. That is indicative; whether it exists and is active is known only to the Spanish Tax Agency.
How do I check if a company NIF is active?
With the AEAT third-party NIF census check, using Cl@ve or a digital certificate. It answers identified, not identified, deregistered or revoked.
What does the first letter mean?
The legal form under Order EHA/451/2008: A public limited company, B private limited company, N foreign entity, W permanent establishment, and so on.
Are CIF and NIF the same?
Yes. CIF was the name until 2007; since Royal Decree 1065/2007 it is called NIF, with the same format.
Is the control character algorithm official?
No regulation publishes it. This tool uses the commonly used method and only gives an indicative result.
Do you store the number I type?
No. It is calculated in your browser and never leaves your device.
About
About this validator
Built by Black Wings, a software studio in Valencia (Spain) working with small and medium businesses. Our validators are free, single-purpose tools that show how we work.
- Entity letters: Order EHA/451/2008, arts. 2 to 5.
- Composition and revocation: Royal Decree 1065/2007, arts. 22 and 147.
- Control character: commonly used method, no official source.
- Reviewed: 22 November 2026.
Privacy
What happens to the number you type
It never leaves your browser. It is calculated with JavaScript on your device: not sent to any server, not stored, not recorded in any analytics.
The links to the Tax Agency and VIES do not carry the number. More in our privacy policy.
Other validators
More free validators
Need this inside your own software?
Validating IBANs and tax IDs when a customer signs up, checking whole lists or connecting invoicing to the bank: that is the kind of work we do at Black Wings.
Tell us about it