Local format checks

Card Number Validator

Check characters, supported lengths and the Luhn checksum separately. A passing check does not establish an account.

Try a fixed example, or enter your own synthetic input:

Uses this site's documented test profile. Entered values are not stored or sent by this tool. It does not check payment acceptance, account activity or funds.

Read the result one check at a time

Use a synthetic card number to inspect four independent questions: are its characters allowed, which configured prefixes remain possible, does its length fit the selected profile, and does its Luhn checksum pass? The tool performs these checks locally without submitting the input to an issuer or payment gateway.

Try the example buttons above before pasting a fixture. Passing format and Wrong check digit differ by one digit. Mixed characters demonstrates an error that must not be silently removed. Ambiguous prefix shows why a partial number needs its own state.

ExampleWhat the result should show
4111 1111 1111 1111Allowed separators removed; Visa profile and length match; Luhn passes
4111111111111112Same prefix and length; Luhn fails
4111x111111111111Character error; no brand or checksum result manufactured from the remaining digits
6Discover, Maestro and UnionPay remain possible; no selected brand or checksum result
A complete 17-digit JCB fixtureJCB profile length supported; checksum assessed separately
An unknown prefix with a passing checksumPrefix unresolved; checksum still reported as a separate fact

Input normalization has an explicit boundary

Only ASCII digits and three separators are accepted: ordinary space, nonbreaking space and the ASCII hyphen. Tabs, line breaks, letters and other numeral systems are reported as unsupported characters. The original field remains editable and unchanged. Numeric values passed to the downloadable API are rejected instead of being converted back to strings after precision may already have been lost.

export function normalizeInput(input) {
  if (typeof input !== 'string') return { status: 'type', digits: '' };
  // Accept only ASCII digits, ordinary/NBSP spaces and ASCII hyphens.
  if (/[^0-9 \u00a0-]/u.test(input)) return { status: 'characters', digits: '' };
  const digits = input.replace(/[ \u00a0-]/g, '');
  return { status: digits ? 'ok' : 'empty', digits };
}

This policy is a deliberate input contract, not a claim that every checkout should handle international input the same way. If your component performs additional normalization, test that transformation explicitly before applying the format checks.

A supported profile is not a universal card specification

The length comparison lists what this validator supports alongside what the generator emits. The profile includes 17- and 18-digit JCB fixtures and 19-digit Diners fixtures; it does not claim to cover every product issued by every network. An unknown prefix means the configured rules do not resolve it.

The prefix-detection guide explains how pending specific patterns prevent a broad fallback from selecting a brand too soon. Use BIN analysis to inspect candidate prefixes and six/eight-digit slices; neither tool looks up the issuing bank, country or funding type.

Run the same checks outside the page

Download the shared validation bundle and extract it into one directory. With Node.js 22 or later, run:

node --test card-validation.test.mjs luhn.test.mjs

The bundle includes the profile, the module imported by this tool, fixed input cases and their expected results. It also includes the four-language checksum examples. No API key, package install or payment request is needed. The test runner checks empty input, invalid characters, partial prefixes, length boundaries and the generated profiles’ compatibility.

The code examples guide explains the Python, PHP and Ruby runners. The Luhn walkthrough explains the arithmetic when a mismatch needs investigation.

Decide submission policy in your integration

This tool reports results; it never decides whether a merchant should submit a payment. Use your provider’s field requirements and your configured validation policy. In particular, do not turn a failed checksum into a passing one just because a brand is UnionPay: the UnionPay policy example keeps the arithmetic result separate from the local decision.

For fresh format inputs, use the all-network generator. For gateway approvals, declines or authentication, use provider-published sandbox fixtures. Generated numbers and these local checks do not establish a real account, usable security code or available funds.

Frequently Asked Questions

Why is a number with an embedded letter rejected?
The input contract permits ASCII digits, ordinary spaces, nonbreaking spaces and hyphens. Other characters produce an error; the tool does not remove them to manufacture a passing number.
Why does a single 6 not select Maestro?
Several configured brands can still match that input. The result lists the candidates and waits for enough digits to resolve the prefix within this site’s profile.
Can Luhn pass while another check fails?
Yes. A checksum can pass for an unsupported length or an unknown prefix. The separate result rows show those facts independently; a checksum pass is not an account or payment approval.
Does the validator accept the longer JCB examples?
Its current profile supports 16, 17, 18 and 19 digits for the configured 3528–3589 range. The JCB generator still produces 16 digits. Both scopes are listed in the length reference.