/^/
EasyInternational3 min read

Indian PIN Code Regex

Validates a 6-digit Indian postal PIN code, requiring the first digit to be 1-9 since no PIN code region starts with 0.

#pin-code#india#postal-code#validation#international#address

Regex Pattern

^[1-9][0-9]{5}$

Pattern Breakdown

Hover over a token to see what it does.

^[1-9][0-9]{5}$
TokenMeaning
^Anchors the match to the start of the string
[1-9]First digit must be 1-9; Indian PIN codes never start with 0
[0-9]{5}The remaining five digits, each 0-9
$Anchors the match to the end of the string

Detailed Explanation

What it does

This pattern validates that a string is exactly 6 digits long and does not start with 0, matching the structure of India Post's PIN (Postal Index Number) code system, where the first digit identifies one of nine postal zones.

Why it works

India Post divides the country into 9 numbered postal zones (1-9), so every real PIN code's first digit falls in that range; a leading `[1-9]` followed by exactly five more digits captures both the zone constraint and the fixed 6-digit length in one pattern.

Common use cases

  • Validating PIN code fields on Indian address, shipping, or KYC forms
  • Filtering bulk-uploaded address datasets for structurally invalid PIN codes
  • Client-side format checks before looking up a PIN code against a postal/pincode API
  • Extracting PIN-code-shaped tokens from freeform address text

Edge cases

  • A structurally valid 6-digit code like '999999' passes format validation even if it isn't an assigned, real PIN code
  • PIN codes with surrounding text, like 'PIN: 110001', are rejected since the anchors require the whole string to be just the 6 digits
  • Codes with spaces or hyphens, such as '110 001', fail this compact pattern
  • A PIN code entered with a leading zero (rare/invalid in practice) is correctly rejected

Limitations

  • Does not verify the PIN code is actually assigned to a real post office or locality
  • Cannot confirm the entered PIN code matches the rest of the address (city, state)
  • Does not implement any checksum, since India's PIN code system has none
  • Real verification requires a postal lookup API or India Post's official PIN code directory

Interactive Tester

Edit the pattern or text below — matching runs live in your browser.

110001 400001 560001

Test Cases

Editable — add your own inputs to see if they pass.

InputExpectedResult
Pass
Pass
Pass
Pass
Pass
Pass
Pass
Pass

Language Variants

Production-ready examples in 12 languages.

const pinCodeRegex = /^[1-9][0-9]{5}$/;
console.log(pinCodeRegex.test('110001')); // true

Common Mistakes

Using [0-9]{6} for all six digits, which wrongly accepts PIN codes starting with 0

Fix: Constrain the first digit to [1-9] since India's postal zones are numbered 1 through 9

Assuming a format-valid PIN code is a real, deliverable location

Fix: Cross-check against an official PIN code / locality lookup API for deliverability

Accepting PIN codes with embedded spaces or the 'PIN' label without stripping them first

Fix: Trim and strip non-digit prefixes/suffixes from user input before running this pattern

Performance Notes

  • A single bounded digit class with fixed length is O(n) with no backtracking risk
  • Cheap enough to run on every keystroke for instant address-form validation feedback
  • Anchors prevent accidental matches on PIN-code-shaped substrings inside longer address strings

Browser Compatibility

EngineSupportedNotes
ChromeYes
FirefoxYes
SafariYes
EdgeYes
Node.jsYes