- Total length: 18 digits
- Bank code: 3 digits (positions 1-3)
- Branch code: 3 digits (positions 4-6)
- Account number: 11 digits (positions 7-17)
- Check digit: 1 digit (position 18)
345Branch Code3 digits (positions 4-6)Identifies the specific branch or plaza.
67890123456Account Number11 digits (positions 7-17)Unique account identifier within the branch.
7Check Digit1 digit (position 18)Validates the entire CLABE using a weighted algorithm.
CLABE Validation Algorithm
The CLABE validation algorithm uses a weighted sum calculation to verify account number integrity. Each of the first 17 digits is multiplied by a specific weight (following the pattern 3, 7, 1 repeatedly), then all products are summed. The check digit is calculated as(10 - (sum % 10)) % 10 and must match the 18th digit for the CLABE to be valid:
RFC (Tax ID) Validation
RFC (Registro Federal de Contribuyentes) is Mexico’s tax identification system used alongside CLABE numbers. RFC identifiers come in two distinct formats depending on whether they’re for individuals or businesses:
Each RFC format contains specific components that encode different types of information:
The following functions provide RFC validation and type detection capabilities:
RFC Validation
RFC Validation
This function validates RFC format using regex patterns to ensure proper structure for both individual and business formats:
RFC Type Detection
RFC Type Detection
This function determines whether an RFC belongs to an individual or business based on its length:
Common Validation Patterns
Common validation patterns involve checking the combined length of CLABE and RFC, ensuring they match the expected formats, and validating the check digits for each component. The following functions provide comprehensive validation for Mexican banking data:Complete Banking Data Validation
Complete Banking Data Validation
CLABE Formatting for Display
CLABE Formatting for Display
Account Masking for Security
Account Masking for Security
Error Messages
When validation fails, your application should handle these standardized error codes to provide clear feedback to users. Each error code corresponds to a specific validation failure with localized message support:
The following code provides a centralized error handling system with support for both English and Spanish messages. Use the
get_error_message() function to retrieve localized error messages based on error codes returned by validation functions:
See also
You can find more information about the Mexican banking system in the following guides:- Refer to Institution Codes for Mexican bank codes and account types.
- Read about CLABE Component Extraction to extract components from CLABE numbers.
- See the complete Mexican Banking Reference.

