Skip to main content
CalcHive

Regex for US ZIP Code

Matches US ZIP codes in 5-digit format (12345) and ZIP+4 format (12345-6789).

Pattern

/^\d{5}(-\d{4})?$/

Pattern Breakdown

TokenExplanation
^Start of string
\d{5}Five-digit ZIP code
(-\d{4})?Optional +4 extension (dash and four digits)
$End of string

Test Examples

InputMatch?
90210Match
10001-1234Match
1234No match
123456No match

Common Use Cases

  • Address form validation
  • Shipping calculator input
  • Location-based services

Variations

^\d{5}$

5-digit ZIP only

Want to test this pattern with your own data?

Open the Regex Tester