Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Credit Card Number Validator (Luhn Check)

Validate card numbers with the Luhn check and detect the card brand.

Checked in your browser and never sent anywhere. Even so, do not paste real card numbers into websites; use the test numbers below.

Official test card numbers

Published by payment providers for sandbox testing. They pass the Luhn check but are not real cards.

BrandNumberActions
Visa4242 4242 4242 4242
Visa4111 1111 1111 1111
Visa4012 8888 8888 1881
Visa (debit)4000 0566 5566 5556
Mastercard5555 5555 5555 4444
Mastercard (2-series)2223 0031 2200 3222
Mastercard5105 1051 0510 5100
Mastercard (debit)5200 8282 8282 8210
American Express3782 822463 10005
American Express3714 496353 98431
Discover6011 1111 1111 1117
Discover6011 0009 9013 9424
Diners Club3056 9300 0902 0004
Diners Club (14-digit)3622 720627 1667
JCB3566 0020 2036 0505
JCB3530 1113 3330 0000
UnionPay6200 0000 0000 0005
Use via API

Check a payment card number's format: brand from its IIN prefix, length and Luhn check digit. Does not contact any bank or check whether the card exists. Send JSON, get JSON back.

POST https://pithlab.com/api/v1/tools/credit-card-validator

curl https://pithlab.com/api/v1/tools/credit-card-validator \
  -H "Authorization: Bearer $PITHLAB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"number":"4111 1111 1111 1111"}'

Fields and responseOpenAPI documentGet an API key

About the Credit Card Validator

Check a card number with the Luhn algorithm, detect Visa, Mastercard, Amex and other brands, check the length and format it. Bulk mode included, all offline.

How to use the Credit Card Validator

  1. Type or paste a card number. Spaces and dashes are ignored.
  2. Read the detected brand, the Luhn check result and whether the length suits that brand.
  3. Switch to Bulk to check many numbers at once, one per line, then copy the results.
  4. Use the payment providers' published test numbers below when you need a sample, never a real card.

Examples

Stripe's Visa test number

Input

4242424242424242

Output

4242 4242 4242 4242: Visa, valid (Luhn pass, length OK)
American Express test number

Input

378282246310005

Output

3782 822463 10005: American Express, valid (Luhn pass, length OK)
A typo fails the Luhn check

Input

4242 4242 4242 4241

Output

4242 4242 4242 4241: Visa, invalid (Luhn fail, length OK)

Frequently asked questions

Does a valid result mean the card is real?

No. The Luhn check only catches typing mistakes. A number can pass it and still not exist, be expired or be blocked. Only the card issuer can say whether a card is real and active, through a payment authorisation.

Should I paste my real card number here?

You should never paste a real card number into any website you do not need to pay on. This tool runs entirely in your browser and sends nothing anywhere, but there is no reason to risk it: use the published test numbers instead.

How does the Luhn algorithm work?

Starting from the rightmost digit, double every second digit, subtract 9 from any result over 9, then add all the digits. If the total ends in 0, the number passes.

How is the card brand worked out?

From the first digits, the Issuer Identification Number. For example, Visa starts with 4, Mastercard with 51 to 55 or 2221 to 2720, and American Express with 34 or 37.

Why doesn't this generate card numbers?

Payment providers publish official test numbers for development, so there is no need to generate new ones. Those are listed on this page.