Phone Number Regex Pattern & Tester
Test phone number validation regex patterns with real-time matching. Copy regex patterns for US numbers, international formats, and various phone number styles.
Regex Tester
Test regular expressions in real time with match highlighting and capture groups.
Matches (0)
Enter a pattern and test string to see matches
US phone number regex
Match US phone numbers in various formats: ^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$ — this handles formats like (555) 123-4567, 555-123-4567, +1 555 123 4567, and 5551234567. It allows optional country code, parentheses, hyphens, dots, and spaces as separators between digit groups.
// JavaScript — validate US phone numbers
const usPhone = /^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/;
usPhone.test("(555) 123-4567"); // true
usPhone.test("555-123-4567"); // true
usPhone.test("+1 555 123 4567"); // true
usPhone.test("5551234567"); // true
# Python
import re
pattern = r"^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$"
re.match(pattern, "(555) 123-4567") # MatchInternational phone number regex
For international numbers: ^\+[1-9]\d{1,14}$ (E.164 format) matches numbers like +14155551234 and +442071234567. For user-facing input that allows formatting: ^\+?\d{1,4}[-.\s]?\(?\d{1,4}\)?[-.\s]?[\d-.\s]{4,15}$ handles most international formats with optional formatting characters. For production validation, consider using the libphonenumber library instead of regex alone.
// E.164 format — the international standard for phone storage
const e164 = /^\+[1-9]\d{1,14}$/;
e164.test("+14155551234"); // true (US)
e164.test("+442071234567"); // true (UK)
e164.test("+81312345678"); // true (Japan)
e164.test("14155551234"); // false (missing +)Frequently Asked Questions
What regex matches all phone number formats?
No single regex perfectly matches all global phone formats. For best results, use E.164 format (^\+[1-9]\d{1,14}$) as a storage standard, and a lenient regex for input validation. Libraries like libphonenumber provide the most accurate validation.
How do I validate phone numbers in JavaScript?
Use regex for basic format checking: /^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(phone). For production validation, use the google-libphonenumber library which handles international formats and carrier validation.
Related Inspect Tools
TypeScript 6.0 Migration Checker
Analyze your tsconfig.json for TS 6.0 breaking changes, deprecated options, new defaults, and get a readiness grade with fixes
AI Code Security Scanner
Scan JavaScript and TypeScript code for vulnerabilities — hardcoded secrets, injection, XSS, SSRF, prototype pollution, and 20+ security checks
Code Complexity Analyzer
Analyze JavaScript and TypeScript code for cyclomatic complexity, cognitive complexity, nesting depth, and maintainability index with per-function metrics
GitHub Actions Validator
Validate GitHub Actions workflow YAML files for syntax, triggers, job structure, step config, needs dependencies, and deprecated actions