Check whether a string has the shape of a payment-card number.
The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.
Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.
The pattern accepts digit groups with optional spaces or hyphens and constrains common card lengths; a separate Luhn check can test the checksum. Shape and checksum do not prove an active account.
visa
Credit Card Regex (visa):
^4\d{12}(?:\d{3})?$
Visa: starts with 4, 13 or 16 digits
Prefix: 4
Note: This validates format only, not Luhn checksum.
Checkout forms, payment imports, and card-number test fixtures check card shape.