Credit Card Validator

Detect the card network, run the Luhn check, and verify the length.

Credit Card Validator

Paste a card number and this tool detects the network, runs a Luhn check digit test, and verifies the length for that network.
Paste several numbers, one per line, to validate them all at once.


Load an example

Test Card Generator
Produces one or more random numbers (up to 10 at a time). Use them for testing, never for anything real.
Ready to validate card numbers.


Overview

This Credit Card Validator tells you whether a payment card number is structurally sound and which payment network issued it. It reads the first digits of the number to identify the network, applies the Luhn check digit algorithm to the whole number, verifies that the length matches what that network allows, and reports a clear verdict.

What it does: Enter any Visa, Mastercard, American Express, Discover, JCB, Diners Club, UnionPay or Maestro number and the tool returns its network, validation result, length check, security code details, and the expected digit grouping. Paste multiple numbers, one per line, and it builds a color-coded table with a Pass or Fail verdict for each. A built-in test card generator produces random Luhn-valid numbers for any supported network.

Why it is useful: Card numbers are checked by their structure before they ever reach a payment processor. Catching a mistyped digit before submitting a form saves a failed transaction and a confused customer, developers can test checkout logic with numbers that pass format checks, and anyone auditing a list of cards can quickly split the valid ones from the typos. Because everything runs locally in your browser, the numbers you paste never leave your device.

What it is built with: The detector uses the ISO/IEC 7812 issuer identification number (IIN) prefixes assigned to each card network, and validation is handled by the Luhn algorithm, the mod-10 check digit formula used by all major payment networks. Both run in a single JavaScript file in your browser, so there is no server, no account, and no data collection.


Supported Card Networks

The card number ranges this tool recognizes, their valid lengths, and the security code each network uses.

Network Starts With Valid Lengths Security Code
Visa413, 16, 19CVV (3 digits)
Mastercard51–55, 2221–272016CVC (3 digits)
American Express34, 3715CID (4 digits)
Discover6011, 622126–622925, 644–649, 6516, 19CID (3 digits)
JCB3528–358916, 17, 18, 19CVV (3 digits)
Diners Club300–305, 36, 38–3914, 16, 19CVV (3 digits)
UnionPay6216, 17, 18, 19CVN (3 digits)
Maestro5018, 5020, 5038, 6304, 6759, 6761–676312–19CVV (3 digits)

A card number is assembled from three parts: the first six to eight digits are the issuer identification number (IIN) that identifies the network and issuing bank, the middle digits are the individual account number, and the final digit is the Luhn check digit. Some ranges overlap between networks, since schemes share prefixes under co-badging agreements (for example, the 62 range belongs to both Discover and UnionPay). When that happens, the tool lists every matching network next to the result.


How to Use This Tool

1. Enter a number: Paste or type it into the "Input" field, or use "Load an example" to start with a sample.

2. Validate: Click the "Validate Cards" button. A single number opens a result card with the network, validation and length checks, security code details, and the expected grouping. Several numbers produce a color-coded table.

3. Generate test cards: In the "Test Card Generator" panel, choose a network and length, set how many numbers you need, then click "Generate Test Card" for random Luhn-valid numbers you can copy into a checkout form or test suite.

4. Use the results: Copy or download the verdict with the Copy or Download links below the output area, or press "Clear & Reset" to start over.


Examples

Every example loads a sample number - click "Try it", then press "Validate Cards" to see its verdict.

1. A valid Visa card

A correctly formed 16-digit Visa number: the prefix is 4, the validation passes, and 16 is a valid length, so the verdict is Valid.

Input
4571219113035643
Output
Status: Valid
Network: Visa
Digits: 16
Validation: Pass
Security code: CVV (3 digits)
Grouped: 4571 2191 1303 5643
Visa number passes the Luhn check and uses a valid length for its network.

2. One mistyped digit is caught by Luhn

This is a valid Visa format with its final digit changed from 3 to 2. It still looks like a normal 16-digit card, but the validation fails and the verdict is Invalid.

Input
4571219113035642
Output
Status: Invalid
Network: Visa
Digits: 16
Validation: Fail
Security code: CVV (3 digits)
Grouped: 4571 2191 1303 5642
Fails the Luhn check digit test, so one digit is probably mistyped.

3. Right prefix, wrong length

This number carries an American Express prefix (34) and passes validation, but it is 16 digits long. Amex only issues 15-digit numbers, so the length check fails.

Input
3403755079215634
Output
Status: Invalid
Network: American Express
Digits: 16
Validation: Pass
Security code: CID (4 digits)
Grouped: 3403 7550 7921 5634
Length 16 is not valid for American Express (expected 15).

4. A quick batch scan

Five numbers, one per line. Each gets its own row: two valid, one validation failure, one unrecognized prefix, and one that is too short.

Input
4571219113035643
4571219113035642
370578607216238
123456789012345
1234
Output
Card Number           Network           Validation  Length  Result
4571 2191 1303 5643    Visa              Pass        16      Valid
4571 2191 1303 5642    Visa              Fail        16      Invalid
3705 786072 16238     American Express  Pass        15      Valid
1234 5678 9012 345     Unknown           Fail        15      Unrecognized
1234                  Unknown           Fail        4       Too short

Features & Options

Network detection: Every new number is matched against the IIN prefix ranges of all eight supported networks. A two-digit prefix is usually enough to narrow it down, so a number that starts with "5" is flagged as Mastercard while "34" points to American Express.

Luhn check digit test: The final digit of every card number is a check digit computed from the rest. The tool runs the standard mod-10 algorithm over the whole number, catching almost any single mistyped digit. The Visa number 4571 2191 1303 5643 passes, while 4571 2191 1303 5642 fails and is flagged Invalid.

Length validation per network: Each network only issues certain lengths. Visa allows 13, 16 or 19 digits; Amex allows exactly 15. A 16-digit number that starts with 34 passes the Luhn test but still fails here, because American Express never issues 16-digit cards.

Expected grouping preview: The result card shows how the number should be spaced for display. Standard cards group as 4-4-4-4, Amex as 4-6-5, Diners as 4-6-4, so 370578607216238 is shown as 3705 786072 16238.

Batch validation: Paste several numbers, one per line, and the output becomes a color-coded table with the grouped number, network, validation result, length, and an overall verdict per row. Great for cleaning up a list before importing it anywhere.

Test card generator: Pick a network, a length, and how many numbers you need (up to 10), and the generator returns random numbers with valid prefixes and correctly computed Luhn check digits. Handy for developers exercising checkout forms and payment validation logic without inventing numbers by hand.

Copy & Download results: "Copy" copies the verdict text or the whole batch table to your clipboard; "Download" saves it as a text file, ready for a QA report or a ticket.


When to Use This Tool?

Before submitting a checkout form, run the card number through this validator to confirm the digits are well-formed and the length matches the network, so a typo never becomes a declined charge.

While developing an online store, use the generator to produce Luhn-valid test numbers for each network and the validator to confirm your form rejects misplaced digits and wrong lengths.

When auditing a saved list of card numbers, paste the whole batch in one go and separate the valid rows from the validation failures, wrong lengths, and unrecognized prefixes.

When demonstrating how payment validation works, Luhn and IIN checks make practical, browser-based examples that need no server.


What Not to Do With This Tool

Do not treat "Valid" as a working card: A Valid result only means the number is structurally well-formed. It says nothing about whether the card is active, funded, or belongs to anyone, so never let it influence a real payment decision.

Do not use this tool to check live or stolen card numbers: Sorting through batches of real card numbers to see which ones pass is carding, and it is illegal in almost every jurisdiction. If you need to validate real numbers, do it only for cards you legitimately own, and not to verify their spending power.

Do not mistake it for a fraud check or a bank lookup: The tool identifies the card network, not the issuing bank, country, or cardholder. Do not rely on it to detect fraud, block payments, or verify identity.

Do not try to buy anything with the generated test cards: The generator builds numbers that belong to no real account. They are for code testing and form validation only, and a payment processor will simply reject them or report a general failure.

Do not enter real card numbers without a reason: Processing happens locally and nothing is sent anywhere, but entering a real full card number into a website is always worth avoiding unless you genuinely need to check it.

Do not keep validated lists of real numbers: If you paste a batch of real numbers, clear the input and any downloaded files afterward. This tool does not store anything, and you should not store the lists either.


FAQs

FAQ 1: Is it safe to paste my real card number here?
Answer: All processing happens locally in your browser, and nothing you paste is sent to or stored on any server. As a security habit, still avoid entering complete real card numbers unless you truly need to.

FAQ 2: A "Valid" result means the card works right?
Answer: No. "Valid" only means the number is well-formed, meaning the prefix belongs to a known network and the Luhn check digit passes. Whether the card is active, funded, or chargeable can only be confirmed by a payment processor, and this free tool does not connect to one.

FAQ 3: Why does my number match more than one network?
Answer: A few card ranges are shared between networks under co-badging agreements, most commonly the 62 range used by both Discover and UnionPay. The result card lists every matching network, and the first one in the list is used for the length check.

FAQ 4: Which card networks does this tool recognize?
Answer: Visa, Mastercard, American Express, Discover, JCB, Diners Club, UnionPay, and Maestro. Any number outside these ranges is reported as unrecognized.

FAQ 5: Can it validate the security code or expiry date?
Answer: No, those details are not part of the card number. The tool does show the security code name and length each network uses, so you know you are being asked for the right number of digits.

FAQ 6: A generated test card passes here but is rejected elsewhere. Why?
Answer: The generator builds numbers that are structurally valid but belong to no real account, and many payment processors require a specific known test card. For development sandboxes, use the exact test numbers your processor documents instead.


Tools Worth Trying

TextToolz

The Ultimate Text Tools

TextToolz works seamlessly to let you convert and design your text. It is fast, reliable and secure. Trusted by thousands of users.