Credit Card Validator — Free Online Tool

Validate credit cards: Luhn algorithm check, card type detection (Visa, Mastercard, Amex), BIN lookup. Check card number format, expiry, CVV validation.

Use this free online Credit Card Validator directly in your browser. No signup required, no data leaves your device. Part of Utilier — a collection of 133+ developer utilities.

What is Credit Card Validator (Luhn Algorithm, Card Type, BIN Checker)?

Credit card validator checks card number validity using Luhn algorithm (checksum formula detecting typos), identifies card type (Visa, Mastercard, American Express, Discover) from number pattern, validates format (length, digits only), checks expiry date (not expired), validates CVV length (3-4 digits). Features: BIN (Bank Identification Number) lookup (first 6-8 digits identify issuer), test card numbers (for development: 4111111111111111 = test Visa), batch validation (multiple cards), format detection (spaces/dashes ignored: '4111-1111-1111-1111' = '4111111111111111'). Use cases: e-commerce checkout (validate before payment), form validation (real-time feedback), fraud detection (invalid cards), testing (generate/validate test cards), BIN analysis (identify issuing bank).

  • Luhn algorithm: Checksum formula: double every 2nd digit from right, sum all digits, result % 10 = 0 (valid). Example: 4532015112830366 → valid. Detects: single-digit errors, adjacent digit swaps (90% of typos). Not secure (predictable pattern).
  • Card type detection: First digits identify type: 4 = Visa, 51-55 = Mastercard, 34/37 = Amex, 6011/65 = Discover. Length: Visa 13-19, Mastercard 16, Amex 15. Example: 4111... (starts 4, 16 digits) = Visa.
  • Format validation: Checks: digits only (no letters), correct length (13-19 digits), valid ranges. Ignores: spaces, dashes (formatting). Example: '4111-1111-1111-1111' → '4111111111111111' (valid format).
  • Expiry date check: MM/YY or MM/YYYY format. Validates: month 01-12, year not past. Example: 12/25 valid if current < Dec 2025. Expired: 01/20 (assuming current > Jan 2020). First of month expiry.
  • CVV validation: CVV/CVC (security code): 3 digits (Visa, Mastercard, Discover), 4 digits (Amex CID on front). Checks: correct length for card type. Example: Visa + CVV 123 (3 digits) = valid, CVV 1234 (4 digits) = invalid.

Why use credit card validator?

Catch typos before payment processing (save transaction fees). Provide instant feedback in forms.

  • Prevent payment errors: User types '4111111111111112' (typo: last digit wrong). Luhn check fails → show error before submit. Avoids: failed payment, transaction fee, frustrated customer. Fix typo: '...1116' → valid.
  • Real-time form validation: User types card number → validate on blur/keyup. Instant feedback: checkmark (valid) or error (invalid). Better UX (catch errors early). Example: '4111' → typing... '4111111111111111' → ✓ valid Visa.
  • Detect card type: User types 4111... → show Visa logo. Types 5111... → Mastercard logo. Visual confirmation (user knows card type detected). Auto-set CVV length (3 for Visa, 4 for Amex).
  • Test payment flows: Development/staging: use test card 4111111111111111 (valid Luhn, processes as test). Validate works without real cards. Test: error handling (invalid cards), success flows (valid cards).
  • Fraud detection (basic): Invalid Luhn + high-value purchase = suspicious (random numbers?). Or many failed validation attempts (guessing cards). Flag for review. Not foolproof (valid format ≠ real card).
  • BIN analysis: BIN 411111 = Visa (test card). BIN 411112 = Bank of America Visa. Identify: issuing bank, card level (standard, gold, platinum), country. Use: offer bank-specific promotions, fraud checks (unusual country).

When to use credit card validator

Use whenever processing or validating credit card data.

  • E-commerce checkout forms (validate before payment).
  • Payment gateway integration (pre-validate client-side).
  • Real-time form validation (instant feedback).
  • Testing payment systems (validate test cards).
  • Fraud detection systems (basic validation check).
  • BIN lookup (identify card issuer).
  • PCI compliance (validate format before storage).
  • Customer service (verify card numbers)

How to use credit card validator

Enter card number, expiry, CVV to validate. Tool checks Luhn, type, format.

  1. Enter card number: Type 16-digit number: 4111111111111111 (spaces/dashes optional: 4111-1111-1111-1111). Tool: removes formatting, validates digits only, checks length (13-19).
  2. View validation result: Luhn check: valid ✓ or invalid ✗. Card type: Visa, Mastercard, Amex, Discover (with logo). BIN: issuing bank/country (if lookup enabled). Error: specific issue (invalid Luhn, wrong length, etc.).
  3. Enter expiry date: Format: MM/YY (12/25) or MM/YYYY (12/2025). Validates: month 01-12, year ≥ current year. Current month/year: checks not expired. Example: 12/25 valid if today < Dec 1, 2025.
  4. Enter CVV: 3 or 4 digits (depends on card type). Visa/Mastercard: 3 digits (123). Amex: 4 digits (1234). Tool validates: correct length for detected card type. No Luhn check (CVV is security code, not checksum).
  5. Check detailed results: Output shows: Luhn valid/invalid, card type, BIN info (bank, country), format issues. Example: '4111111111111111' → Valid Visa, Test card, Luhn ✓, Length ✓, BIN: 411111 (test issuer).
  6. Use test cards: Development: use official test cards. Visa: 4111111111111111, 4012888888881881. Mastercard: 5555555555554444. Amex: 378282246310005. All pass Luhn (valid format), but process as test (no charge).

Key features

  • Luhn algorithm check: Detects 90% of typos (single-digit errors, transpositions). Formula: double every 2nd digit from right, sum all, modulo 10 = 0. Example: 4532015112830366 valid, 4532015112830367 invalid (last digit typo).
  • Card type identification: Detects: Visa (4), Mastercard (51-55, 2221-2720), Amex (34, 37), Discover (6011, 65), Diners (36, 38), JCB (3528-3589), UnionPay (62). Shows logo, expected length, CVV format.
  • Format validation: Checks: all digits (no letters/special chars), length 13-19 (varies by type), valid BIN ranges. Ignores: spaces, dashes, formatting chars (auto-removed). Example: '4111 1111 1111 1111' → valid.
  • Expiry date validation: Checks: MM (01-12), YY/YYYY (≥ current year), not expired (compares month/year). Expiry: first day of month (12/25 = Dec 1, 2025). Formats: MM/YY, MM/YYYY, MM-YY, MMYY.
  • CVV length check: Validates: 3 digits (Visa, MC, Discover), 4 digits (Amex). Matches card type (Amex detected → expects 4-digit CVV). No checksum (CVV random security code).
  • BIN lookup: First 6-8 digits = BIN (Bank Identification Number). Identifies: issuing bank, card brand, country, card level (debit/credit, standard/premium). Example: 411111 = Visa Test Card, 542418 = Mastercard Australia.
  • Test card detection: Recognizes official test cards: 4111111111111111 (Visa), 5555555555554444 (MC), 378282246310005 (Amex). Flags as test (for development). Passes Luhn but not real (no charge).

Common use cases

  • Checkout validation: E-commerce: user enters card. Validate client-side: Luhn check, type detection, expiry. Instant error: 'Invalid card number' (Luhn fail) or 'Card expired' (past expiry). Prevents submit (fix before payment).
  • Form feedback: Credit card field: user types. On blur: validate. Show: checkmark (valid), card logo (Visa detected), error message (invalid Luhn). Real-time: better UX (catch typos immediately).
  • Payment gateway prep: Before sending to Stripe/PayPal: validate format. Avoid: API call with invalid card (fails, wastes request). Pre-check: Luhn, length, type. Only valid cards → gateway.
  • Test environment: Staging payment system: use test card 4111111111111111. Validates: Luhn passes, Visa detected, CVV 123 valid, expiry 12/25 valid. Process: succeeds (test mode), no charge.
  • Fraud detection: Order with card 1234567890123456 (invalid Luhn). Suspicious: random numbers (not real card). Flag for review. Or many attempts (10 invalid cards tried) = card guessing attack.
  • BIN-based routing: Card BIN 411111 (test) → route to test gateway. BIN 542418 (Australia Mastercard) → route to Australian processor (lower fees). BIN determines: processor, region, card features.

Examples

Common credit card validation examples.

Valid Visa

4111111111111111
Valid ✓
Type: Visa
Length: 16
Luhn: Pass
BIN: 411111 (Test Card)

Test card (development use). Passes Luhn. Visa pattern (starts 4, 16 digits).

Invalid Luhn

4111111111111112
Invalid ✗
Luhn: Fail (checksum error)
Possible typo in last digit

Last digit wrong (should be 1, not 2). Luhn check detects error. Fix: change 2 → 1.

Mastercard with spaces

5555 5555 5555 4444
Valid ✓
Type: Mastercard
Length: 16
Luhn: Pass
BIN: 555555

Spaces ignored (formatting). 5555... → Mastercard (starts 51-55). Valid test card.

American Express

378282246310005
Valid ✓
Type: American Express
Length: 15
Luhn: Pass
CVV: 4 digits required

Amex: 15 digits (not 16). Starts 37. CVV: 4 digits (front of card). Test card.

Expired card

Card: 4111111111111111
Expiry: 01/20
Card: Valid ✓
Expiry: Invalid ✗ (expired Jan 2020)

Card number valid. Expiry past (assuming current > Jan 2020). Update expiry date.

Technical reference

Credit card validation specifications:

Luhn algorithm
Step 1: Double every 2nd digit from right. Step 2: If result > 9, subtract 9 (or sum digits). Step 3: Sum all digits. Step 4: Result % 10 = 0 (valid) or ≠ 0 (invalid). Example: 79927398713 → 7+18+9+4+7+6+9+16+7+2+3 = 88 % 10 = 8 (invalid). Change last digit to 0: 88+0-3+0 = 85 + 5 = 90 % 10 = 0 (valid: 79927398710).
Card type patterns
Visa: 4, 13-19 digits. Mastercard: 51-55 or 2221-2720, 16 digits. Amex: 34 or 37, 15 digits. Discover: 6011 or 65, 16 digits. Diners: 36 or 38, 14 digits. JCB: 3528-3589, 16 digits. UnionPay: 62, 16-19 digits.
BIN structure
First 6-8 digits = BIN/IIN (Issuer Identification Number). Digit 1: MII (Major Industry Identifier, 4 = banking). Digits 2-6: issuer ID (bank). Remaining: account number. Checksum: last digit (Luhn). Example: 4111 1111 1111 1116 → BIN 411111, account 111111111, checksum 6.
Expiry validation
Format: MM/YY or MM/YYYY. MM: 01-12. YY: 2-digit year (25 = 2025). Expiry date: first day of month (12/25 = Dec 1, 2025, 00:00). Comparison: current date < expiry date (valid) or ≥ (expired/invalid).
CVV/CVC
CVV (Visa), CVC (Mastercard), CID (Amex), CSC (Discover). Visa/MC/Discover: 3 digits, back of card (magnetic stripe area). Amex: 4 digits, front of card (above card number). Not stored (PCI-DSS: CVV storage prohibited). One-time use (each transaction).
Test card numbers
Visa: 4111111111111111, 4012888888881881, 4222222222222. Mastercard: 5555555555554444, 5105105105105100. Amex: 378282246310005, 371449635398431. Discover: 6011111111111117, 6011000990139424. All pass Luhn, process as test (no charge).
Length limits
Min: 13 digits (Visa). Max: 19 digits (Visa, UnionPay). Most common: 16 digits (Visa, MC, Discover). Amex: 15 (only major card with odd length). Validation: check length matches card type.
Formatting
Display: 4-digit groups (4111 1111 1111 1111) or Amex 4-6-5 (3782 822463 10005). Input: spaces/dashes ignored (auto-removed). Store: digits only (no formatting). Print: first 6 + last 4 (411111******1116, PCI compliance).
PCI-DSS compliance
Storage: can store card number (encrypted), expiry. Cannot store: CVV, track data (magnetic stripe). Display: mask number (****1116). Transmission: HTTPS only. Validation: client-side OK (no storage), server-side requires PCI compliance.
Security note
Luhn valid ≠ real card. Luhn checks format, not existence. Example: 4111111111111111 passes Luhn (test card), but declined if used as real. Real validation: payment gateway (checks bank account). Luhn = typo detection, not authentication.

Common mistakes to avoid

Storing CVV (violates PCI-DSS)

Why it happens: PCI-DSS: CVV storage prohibited (after authorization). Stored CVV = security risk (if breached, cards compromised). Fines: $5,000-$100,000/month for non-compliance.

How to avoid it: Never store CVV (neither database nor logs). Collect for transaction, transmit to gateway, discard immediately. Store: card number (encrypted) + expiry only. CVV: one-time use.

Trusting Luhn alone (not real validation)

Why it happens: Luhn checks format, not card existence. Example: 4111111111111111 passes Luhn (valid format), but declines if used (test card, or non-existent account). False positive: valid format ≠ real card.

How to avoid it: Luhn = pre-validation (catch typos). Real validation: payment gateway (checks bank, balance). Use Luhn client-side (quick feedback), gateway server-side (authoritative check).

Wrong CVV length for card type

Why it happens: Amex CVV = 4 digits (front). User enters 3 digits (back of card habit) → invalid. Or Visa CVV = 3 digits, user enters 4 → error. Mismatch causes payment failure.

How to avoid it: Detect card type first (from number). Set CVV input: 3 digits (Visa, MC, Discover), 4 digits (Amex). Show hint: 'Back of card' or 'Front of card'. Validate length matches type.

Not checking expiry date

Why it happens: Expired card → payment declines. User types valid number, Luhn passes, but expiry 01/20 (past) → transaction fails. User frustration (why declined?).

How to avoid it: Validate expiry client-side: check month 01-12, year ≥ current, not past. Show error: 'Card expired, please update'. Catch before payment (avoid failed transaction).

Rejecting valid formatting (spaces, dashes)

Why it happens: User types '4111 1111 1111 1111' (with spaces, as printed on card). Validation requires no spaces → error: 'Invalid characters'. User confused (copied exactly from card).

How to avoid it: Allow spaces, dashes in input. Strip before validation: '4111 1111 1111 1111' → '4111111111111111' (digits only). Validate clean number. Better UX (accepts card as printed).

Frequently asked questions

What is the Luhn algorithm and how does it work?

Checksum formula: double every 2nd digit from right, sum all digits, result % 10 = 0 (valid). Detects 90% of typos (single-digit errors, adjacent swaps). Not encryption (predictable pattern, not secure).

Can Luhn validation detect a real vs fake card?

No. Luhn checks format only (not existence). Valid Luhn = correct format (no typos). Real validation: payment gateway checks bank account. Example: 4111111111111111 passes Luhn (test card), but not real.

How do I identify card type from the number?

First digits: 4 = Visa, 51-55 = Mastercard, 34/37 = Amex, 6011/65 = Discover. Length: Visa 13-19, MC 16, Amex 15. Example: 5555... (starts 5, 16 digits) = Mastercard.

What are test credit card numbers?

Official test cards for development: Visa 4111111111111111, MC 5555555555554444, Amex 378282246310005. Pass Luhn (valid format), process as test (no charge). Use in staging/dev environments.

Can I store credit card numbers?

Yes (with PCI-DSS compliance). Must: encrypt at rest, mask in UI (****1116), transmit over HTTPS. Cannot store: CVV, magnetic stripe track data. Or use tokenization (gateway stores card, you store token).

What is a BIN number?

Bank Identification Number (first 6-8 digits). Identifies: issuing bank, card brand, country, card level. Example: 411111 = Visa Test, 542418 = Mastercard Australia. Used for: routing, fraud detection, promotions.

Why is my Amex CVV 4 digits instead of 3?

Amex uses CID (4 digits, front of card above number). Visa/Mastercard/Discover use CVV/CVC (3 digits, back of card). Different security code systems. Validate: Amex → expect 4 digits, others → 3 digits.

References

Privacy and availability

  • Runs entirely in your browser — zero server processing
  • No signup or account required
  • Works offline once loaded
  • Fast, lightweight, no external dependencies
  • Available as a browser extension for Chrome and Firefox