Gerador de Cartões de Crédito Falsos

Gere números de cartão com formato válido e validação Luhn para testes

Generating Test Credit Card Numbers for Payment Form Development

Payment form testing requires credit card numbers that pass client-side validation (Luhn checksum, length, prefix matching) without being associated with real financial accounts. Using real card numbers during development risks accidental charges, exposes sensitive data in logs, and violates PCI DSS compliance requirements. The Fake Credit Card Generator produces synthetic card numbers that pass all format validation algorithms while using test-only BIN prefixes that no payment processor will accept for real transactions.

Generate valid-format Visa, Mastercard, American Express, and Discover numbers with correct Luhn checksums, optional CVV codes, and expiry dates. All numbers use test BIN ranges (Bank Identification Numbers) that are reserved for testing and not assigned to any real issuing bank. This ensures your payment form validates correctly while eliminating any risk of processing real payments during development. All generation happens client-side.

Luhn Algorithm Validation

The Luhn algorithm (modulus 10) is the standard checksum used to validate credit card numbers. Every generated number passes this validation:

  • Algorithm: Starting from the rightmost digit, double every second digit; if the result is greater than 9, subtract 9; sum all digits; valid if total mod 10 equals 0
  • Purpose: Catches single-digit transcription errors and most transposition errors
  • Limitation: Luhn validation confirms format correctness only — it does not verify that the number is associated with a real account

Generated numbers always pass Luhn validation, ensuring your payment form's client-side validation logic works correctly without triggering format rejection errors.

Card Network Prefixes and Formats

Each card network uses specific number prefixes (BIN ranges) and lengths:

  • Visa: Starts with 4, 16 digits (or 13 for legacy cards)
  • Mastercard: Starts with 51-55 or 2221-2720, 16 digits
  • American Express: Starts with 34 or 37, 15 digits
  • Discover: Starts with 6011 or 65, 16 digits

The generator uses BIN prefixes from documented test ranges (like Stripe's 4242424242424242 or Braintree's test numbers) that payment gateways recognize as test transactions, ensuring they will never be processed as real payments even if accidentally submitted to production endpoints.

Safe Testing Practices

Important guidelines when using generated test numbers:

  • Never use for fraud: These numbers are exclusively for testing your own payment forms — attempting to use them for purchases will fail and may constitute attempted fraud
  • PCI compliance: Using test numbers during development means no real cardholder data enters your system, simplifying PCI DSS compliance
  • Gateway test mode: Most payment processors have test/sandbox modes that accept specific test numbers — use those for end-to-end testing
  • Form validation only: Generated numbers test client-side validation logic (Luhn, length, prefix) — server-side payment processing requires gateway-specific test credentials

Code Examples

Luhn Algorithm Implementation

// Validate a credit card number with Luhn algorithm
function isValidLuhn(number) {
  const digits = number.replace(/\D/g, '').split('').map(Number);
  let sum = 0;
  let isEven = false;

  for (let i = digits.length - 1; i >= 0; i--) {
    let digit = digits[i];
    if (isEven) {
      digit *= 2;
      if (digit > 9) digit -= 9;
    }
    sum += digit;
    isEven = !isEven;
  }

  return sum % 10 === 0;
}

// Generated test numbers always pass:
console.log(isValidLuhn('4532015112830366')); // true (Visa)
console.log(isValidLuhn('5425233430109903')); // true (Mastercard)
console.log(isValidLuhn('374245455400126'));  // true (Amex)

// Detect card network from number
function detectNetwork(number) {
  if (/^4/.test(number)) return 'Visa';
  if (/^5[1-5]/.test(number)) return 'Mastercard';
  if (/^3[47]/.test(number)) return 'American Express';
  if (/^6(?:011|5)/.test(number)) return 'Discover';
  return 'Unknown';
}

Perguntas Frequentes

Are these credit card numbers real?

No. This tool generates synthetic card numbers using test-only BIN prefixes that do not belong to any real financial institution. The numbers pass Luhn validation for format testing purposes, but they cannot be used for actual transactions.

What is the Luhn algorithm?

The Luhn algorithm is a checksum formula used to validate identification numbers including credit card numbers. It detects single-digit errors and adjacent transposition errors. Every generated card number passes this check, making them suitable for testing payment form validation logic.

Can I use these numbers for testing payment integrations?

These numbers are useful for testing client-side form validation (format checks, Luhn validation, card type detection). For end-to-end payment gateway testing, use your payment provider's official test card numbers (e.g., Stripe's 4242 4242 4242 4242) as they are recognized by the gateway sandbox.

Why do American Express cards have different formats?

American Express cards use 15 digits (vs 16 for Visa/Mastercard/Discover) and a 4-digit CVV (vs 3 digits). This tool correctly generates Amex cards with these specifications, allowing you to test that your payment forms handle varying card formats properly.