HomeRegex LibraryVisa Credit Card Number Regex
100% Client-Side β€’ 0 B Data Leaves Browser
security

Visa Credit Card Number Regex

Matches 13-digit and standard 16-digit Visa debit and credit card numbers starting with 4.

Regular Expression Pattern:
/^4[0-9]{12}(?:[0-9]{3})?$/
Valid Match Example:
4111111111111111
Invalid / Non-Match Example:
5111111111111111

Regex Syntax Breakdown & Explanation

  • β€’^4 : Visa Issuer Identification Number (IIN) always begins with digit 4
  • β€’[0-9]{12} : Base 12 digits
  • β€’(?:[0-9]{3})?$ : Optional 3 additional digits for standard 16-digit cards

Implementation in Popular Languages

JavaScript / TypeScript
const regex = /^4[0-9]{12}(?:[0-9]{3})?$/;
const isValid = regex.test("4111111111111111");
console.log(isValid); // true
Python (re)
import re

pattern = r"^4[0-9]{12}(?:[0-9]{3})?$"
match = re.match(pattern, "4111111111111111")
print(bool(match)) # True
Go (regexp)
package main
import (
  "fmt"
  "regexp"
)

func main() {
  re := regexp.MustCompile(`^4[0-9]{12}(?:[0-9]{3})?$`)
  fmt.Println(re.MatchString("4111111111111111"))
}
Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

The regular expression pattern is /^4[0-9]{12}(?:[0-9]{3})?$/. Matches 13-digit and standard 16-digit Visa debit and credit card numbers starting with 4.