1001Ferramentas
πŸ‡¨πŸ‡¦Validators

Canada Postal Validator

Validate Canadian postal code (A1A 1A1).

Canadian postal code: the alternating ANA NAN pattern

A Canadian postal code is six characters in the pattern A9A 9A9 β€” letter, digit, letter, space, digit, letter, digit. Introduced by Canada Post between 1971 and 1974, it splits into a Forward Sortation Area (FSA) β€” the first three characters β€” and a Local Delivery Unit (LDU) β€” the last three. The validator on this page checks the structural pattern, accepting K1A 0B1 (the famous code of the Prime Minister's Office / Canada Post HQ in Ottawa).

There is no check digit: validity comes from existence in Canada Post's address database. The alternating letter/digit design and the excluded letters make the format very robust against typos and OCR errors β€” a deliberate choice for mechanised sorting.

Anatomy of K1A 0B1

  • 1st letter: postal district / province (e.g. K Eastern Ontario, M Toronto, H MontrΓ©al, V British Columbia, T Alberta).
  • 1st digit: 0 means a rural FSA; 1–9 means urban.
  • FSA (first 3, K1A): the sorting station and neighbourhood.
  • LDU (last 3, 0B1): a city block, a rural route, or a single large-volume recipient.

Excluded letters

  • Never used at all: D, F, I, O, Q, U β€” too easy to confuse with digits or each other.
  • Never used as the first letter: W and Z.
  • So a strict regex is [ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z] \d[ABCEGHJ-NPRSTV-Z]\d.

Where it shows up

  • Address forms: postal code lookup auto-fills city + province; the standard Canadian checkout flow.
  • Shipping & tax: Canada Post rating, plus the FSA helps determine provincial sales tax (GST/PST/HST).
  • Geo & census: Statistics Canada publishes data by FSA.
  • Mock data / testing: generating format-valid codes for fixtures and form QA.

Gotchas

  • Case and space: normalise to uppercase and insert the space before the LDU; k1a0b1 and K1A 0B1 are the same code.
  • Letter O vs digit 0: O is never a letter position, so any apparent O is really a zero β€” a classic OCR fix.
  • Format-valid β‰  deliverable: only Canada Post's database confirms a code is live; the pattern alone doesn't.
  • FSA x0x: the rural marker (second char 0) changes delivery assumptions; don't ignore it.

FAQ

Why letters and digits alternating? The ANA NAN design maximises the number of codes in six characters while staying easy for humans and machines to read β€” far more combinations than six digits.

What does the space mean? Purely a readability separator between FSA and LDU; matching is done after normalising it.

Is there a check digit? No. Validity is by lookup against Canada Post, plus the excluded-letter rules that make the format self-checking against many typos.

Related Tools