Regex for Phone Number Validation
Test regex patterns for phone number validation. Patterns for US, international, and flexible phone number formats.
Open Regex Tester →Phone Number Regex Patterns
Phone numbers vary dramatically by country. The US pattern
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} matches formats like (555) 123-4567, 555-123-4567, and 5551234567. For international numbers, ^\+?[1-9]\d{1,14}$ follows the E.164 standard (up to 15 digits with optional + prefix). Avoid overly strict patterns — they frustrate users with valid but unusually formatted numbers.Best Practices for Phone Validation
- Be flexible: Accept spaces, dashes, dots, and parentheses — strip them before storing.
- Don't over-validate: Phone number rules change. Use regex for basic format checking, then use a library like libphonenumber for full validation.
- Consider international users: Always accept a + prefix and variable lengths for international numbers.
- Store in E.164 format: Normalize to +CountryCode followed by digits (e.g., +14155551234) for consistent storage and comparison.
// US phone number (flexible)
/\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/
// International (E.164)
/^\+?[1-9]\d{1,14}$/
// With optional country code
/^(\+\d{1,3}[-.\s]?)?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}$/