Postal address formatting per country
Normalize and format street addresses according to local postal conventions across 60+ countries.
Problem
Addresses entered in free-form fields arrive with inconsistent casing, missing postal codes, and wrong field ordering. Sending these to shipping APIs causes validation failures and delivery delays.
Solution
A stateless formatting pipeline that accepts a structured address object and returns a localized multi-line string. Country-specific templates handle line ordering, postal code placement, and uppercase rules.
Template map
| Country | Line order | Uppercase |
|---|---|---|
| US | Street → City State Zip | City, State |
| GB | Street → Town → County → Postcode | Postcode |
| DE | Street → Postcode City | Full address |
| JP | Postcode → Prefecture City → Street | — |
Edge cases
- PO Box addresses suppress street line
- Canadian bilingual provinces emit both languages
- Brazilian addresses place complemento after street
- Missing postal code returns null with error code
Full implementation available in the Meridian SDK.