Search docs...

Search docs...

es

RFC

The Registro Federal de Contribuyentes, the tax ID the SAT gives people and companies.

Try it
RFCEKU9003173C9Valid
Type
Company (moral)
Date
March 17, 1990
Homoclave
3C
Check digit
Matches

Validate and parse

import { checkRfc } from "mexico-utils";

checkRfc("EKU9003173C9");
// {
//   ok: true,
//   value: {
//     rfc: "EKU9003173C9",
//     type: "company",
//     date: "1990-03-17",
//     homoclave: "3C",
//     checkDigitMatches: true
//   }
// }
typeWhat it isLength
personPersona física13
companyPersona moral12
genericXAXX010101000 or XEXX01010100013

date is the birth date for people and the incorporation date for companies.

The check digit

The last character is computed with SAT's algorithm and reported as checkDigitMatches. It doesn't make an RFC invalid unless you ask for it:

checkRfc("CACX7605101P9");
// { ok: true, value: { ..., checkDigitMatches: false } }

checkRfc("CACX7605101P9", { checkDigit: true });
// { ok: false, error: "check-digit" }

Why: some real RFCs, mostly old ones, don't match their own check digit. Turning someone away because SAT made a mistake decades ago is worse than letting the RFC through. If you only deal with new RFCs, turn it on.

ErrorMeaning
formatWrong length or characters in the wrong place
dateThe date doesn't exist
check-digitOnly with { checkDigit: true }