Validateur de Carte de Crédit

Validez les numéros de carte de crédit en utilisant l'algorithme de Luhn.

This tool validates card numbers using the Luhn algorithm. Only use test card numbers — never enter real card data.

Test Card Numbers

Comment utiliser Validateur de Carte de Crédit

1

Entrez le numéro de carte de crédit

Entrez le numéro de carte de crédit à 16 chiffres que vous souhaitez valider, sans espaces ni tirets.

2

Cliquez sur Valider

Cliquez sur le bouton « Validate » pour vérifier le numéro de carte bancaire à travers l'algorithme de Luhn.

3

Afficher les résultats

L'outil affichera si le numéro de carte de crédit est valide ou non.

Outils connexes

Credit card validator online: Luhn algorithm check in your browser

Credit card validator online: Luhn algorithm check in your browser

Validate any credit card number against the Luhn algorithm and identify the card type using the credit card validator at ToolHQ. Enter a card number and get an instant result: valid or invalid, plus the detected card type (Visa, Mastercard, Amex, Discover). Validated entirely in your browser using the Luhn algorithm, no card number is ever sent anywhere.

Important: This is a mathematical validation tool. A result of "valid" means the number passes the Luhn checksum formula. It does not mean the card exists, has available funds, is not expired, or is authorised for transactions. No actual payment processing occurs.

The Luhn algorithm is used by developers testing payment forms, QA engineers validating input handling, and anyone who needs to confirm a card number they typed is formatted correctly, without submitting it to a payment processor.

Key Takeaways

  • The Luhn algorithm is a mathematical checksum for credit card numbers, standardised as ISO/IEC 7812
  • Validation confirms the number is correctly formatted, not that the card is active or has funds
  • Identifies card type by prefix: Visa (4xxx), Mastercard (51-55xx), Amex (34xx/37xx), Discover (6011xx)
  • Used by developers for payment form testing and input validation
  • Validated entirely in your browser, no card number is ever sent anywhere

What the Luhn algorithm is and how it works

The Luhn algorithm was invented by Hans Peter Luhn, a computer scientist at IBM, and patented in 1960. It is now an international standard specified in ISO/IEC 7812, the standard for financial services identification card numbering. All major credit card networks, Visa, Mastercard, American Express, and Discover, use card numbers that pass the Luhn check.

The algorithm works as a simple checksum:

  1. Starting from the rightmost digit (the check digit) and moving left, double the value of every second digit.
  2. If doubling a digit produces a result greater than 9, subtract 9 from the result.
  3. Sum all digits in the sequence (both the doubled values and the untouched ones).
  4. If the total sum is divisible by 10 (i.e. sum mod 10 = 0), the number is valid.

This checksum was designed to detect the most common type of input error: a single mistyped digit. The algorithm catches all single-digit errors and most adjacent transpositions (swapping two adjacent digits). It cannot catch every possible error, but it eliminates the majority of accidental typos before a number reaches a payment network.

The algorithm is so simple that it can be computed mentally, in a browser, or on a microcontroller. It requires no network connection and no server. This is why ToolHQ's credit card validator can do everything entirely in your browser with no card number ever sent anywhere.


What the validator tells you and what it does not

This distinction is critical to understand before using the tool.

What a "valid" result means:

  • The card number passes the Luhn checksum formula
  • The number has the correct length for its card type
  • The number's prefix matches a known card network

What a "valid" result does NOT mean:

  • The card account exists
  • The card is currently active
  • The card has available credit or funds
  • The card is not expired
  • The transaction would be approved

To verify any of those things, you need an actual payment gateway authorisation request, which communicates with the card network and the issuing bank. The Luhn check happens much earlier in the process: it catches formatting errors before even attempting to reach the network.


When developers use a credit card validator

Building payment forms: Before submitting a card number to a payment gateway, most well-built payment forms run a Luhn check client-side to catch obvious typos immediately. This avoids wasting an API call on a number that will fail regardless.

Writing and testing input validation: When developing a payment form, you need test card numbers that pass the Luhn check to verify your validation logic. The validator lets you confirm a test number is structurally valid before using it.

QA testing of payment flows: QA engineers need card numbers that pass and fail validation to test error messages and form behaviour. Generating and verifying these test numbers is faster with a dedicated tool.

Explaining Luhn to students or teammates: The visual output of a Luhn check makes it easy to demonstrate how the algorithm works to someone learning about it.

Mini-story: A junior developer was building a checkout form for an e-commerce site. She wanted to show real-time validation feedback as users typed their card number. She used ToolHQ's credit card validator to test her Luhn implementation: she entered a Visa test card number (4111 1111 1111 1111, a standard Luhn-valid test number), verified it showed "valid" and "Visa," then deliberately changed one digit and confirmed the validator caught the error. Her implementation matched the expected behaviour.

Validate a card number now at ToolHQ's credit card validator.


How to use the credit card validator step by step

  1. Open the tool. Visit ToolHQ's credit card validator.
  2. Enter the card number. Type or paste the card number you want to validate. You can enter it with or without spaces or hyphens.
  3. Read the result. The tool shows whether the number is valid or invalid according to the Luhn algorithm, and identifies the card type (Visa, Mastercard, Amex, Discover, or unknown).
  4. Interpret the result. Valid means the number passes the Luhn check. It does not mean the card is active, has funds, or would be approved for a transaction.

Card type identification by prefix

Card type is determined by the first digits (the prefix) of the card number, independently of the Luhn check. These prefixes are defined by the ISO/IEC 7812 standard.

Card network Prefix Common length
Visa 4 16 digits
Mastercard 51–55 or 2221–2720 16 digits
American Express 34 or 37 15 digits
Discover 6011, 622126–622925, 644–649, or 65 16 digits
JCB 3528–3589 16 digits
Diners Club 300–305, 36, or 38 14 digits

Card type identification is useful for showing the correct card logo in a payment form, adjusting the expected number length, and applying network-specific CVV length rules (Amex uses 4 digits; most others use 3).

Mini-story: A startup was building a payment form and wanted to auto-detect the card type as users typed, showing the appropriate card logo. The developer used ToolHQ's credit card validator as a reference to confirm which prefixes corresponded to which card types. She tested Visa (starting with 4), Mastercard (starting with 51), and Amex (starting with 37) numbers to verify her prefix detection logic was correct before shipping the feature.


Frequently asked questions

Can a number pass the Luhn check and still be refused at checkout? Yes, this is very common. The Luhn check only validates the mathematical format of the number. Declined transactions happen for many reasons: insufficient funds, expired card, incorrect billing address, fraud prevention holds, or the card being blocked. None of these are detectable by a Luhn check.

Is it safe to enter my real card number? ToolHQ's validator runs entirely in your browser and sends nothing to any server. However, best practice is to use test card numbers (like 4111 1111 1111 1111 for Visa) for testing rather than real card numbers, since you should always treat real card numbers with the same caution as a password.

What is a Luhn check digit? The last digit of a credit card number is the check digit, calculated so that the entire number passes the Luhn algorithm. If any other digit changes, the check digit will no longer produce a valid sum, making the error detectable.

Does the algorithm work for other identification numbers? Yes. Beyond credit cards, the Luhn algorithm is used in IMEI numbers (mobile phone identifiers), Canadian Social Insurance Numbers, and various government and financial identification numbers.

What is the difference between card validation and card verification? Validation (this tool) is a local mathematical check confirming the number format is structurally correct. Verification is a real-time network check that confirms the card exists, is active, and has available funds, requiring communication with the card issuer.


The short version

ToolHQ's credit card validator uses the Luhn algorithm to check whether a card number is structurally valid and identifies the card type from the prefix. It is the right tool for developers testing payment forms, writing validation logic, and confirming test card numbers, not for verifying real transactions. The check runs entirely in your browser, with no card number sent anywhere. A valid result means the number is correctly formatted, not that the card exists or has funds.

Validate a card number now at ToolHQ.

Related tools: IBAN validator | Data breach checker | Hash generator | Email validator