Validate credit card

Check a payment-card number with the Luhn checksum and mask it for display.

freeworks offlinenothing uploaded
ToolCredit Card Validator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Separators are removed, digits are walked from the right, alternating digits are doubled with nine subtracted above nine, and the total must divide by ten. Prefix heuristics label common networks while all but the first and last four digits are masked.

  • Thirteen to nineteen digits cover common PAN lengths.
  • Network labels are prefix hints, not issuer confirmation.

Worked example

Valid Visa Card
Validate a Visa test card number (Luhn-valid)
Input
											4111 1111 1111 1111
										
Output
												Valid card number
Type: Visa
Masked: 4111 **** **** 1111
											

When to use this

Payment forms, checkout tests, and masked support screens use this check.

Edge cases

  • A Luhn-valid number can still be expired, blocked, or nonexistent.
  • Letters fail before checksum evaluation.
  • Masking changes display only and does not tokenize payment data.

References