Overview
What I Built
International address collection looks simple until you build it properly. The United States uses city, state, and ZIP code; the United Kingdom uses town, county, and postcode; Japan reverses the whole hierarchy and leads with the postal code. A single static form fails all of them, and forcing every country into a US-shaped form silently loses data.
This rebuild is data-driven instead of conditional. A per-country config table drives everything: which fields appear, what they are labeled, the order they render in, whether the subdivision is a dropdown or free text, whether it is required, and the postal code label, pattern, and example. The form has no country-specific if statements in its render path. Adding a country means adding a row to the table, and every country in the list reconfigures the form, including the ones with no special rules.
Validation follows the same principle. It runs locally, on blur and on submit, against the config: required fields, subdivision membership, and postal patterns. A live mailing-label preview shows the address laid out the way that country writes it, so a formatting mistake is visible before anything is submitted. Claude review is still available, but as an optional second step that suggests real-world corrections, not as the thing standing between the user and a valid address. No paid address API, no new service, no uncapped billing.
The rule
The form never guesses. Every rule comes from the config table.
If a rule cannot be stated as data for a country, it does not belong in the form. That is what keeps 193 countries consistent instead of 193 special cases.
Try It
Global Address Form
Pick a country and watch the form reconfigure, or load a preset to see a complete valid address instantly. Validate locally, check the mailing-label preview, then optionally ask Claude for a second opinion.
Mailing-label preview
Select a country to begin.
Architecture
How It Works
The form is a small rendering engine over a data table. Nothing about any specific country lives in the render code, which is why the same code path serves a US ZIP code and a Japanese postal code without branching.
One table row per country: labels, order, subdivision control, postal pattern and example
Fields render in the config order with autocomplete attributes and inline error slots
Required checks, subdivision membership, and postal patterns, on blur and on submit
The address is laid out the way that country writes it, updating as you type
Claude suggests real-world corrections only after local validation passes
Why keep the AI out of the gate? A language model can suggest a better address, but it can also hallucinate a confident correction to a valid one. Deterministic checks never do. So the model advises and the config decides, which is also what keeps the demo free to run: no paid address API, no per-validation billing, no uncapped usage.
Reflection
What I Learned
Rebuilding the demo around a config table changed what I thought the hard parts were:
-
Config tables beat conditionals The first version had a branch per country in the render code, and every new country made the file harder to reason about. Moving every country-specific fact into one table made the render path boring, which is exactly what you want: boring code, interesting data. A new country is now a data entry task, not an engineering task.
-
Postal patterns are the easy half Regexes for postal codes are quick to collect and easy to test. The real work is subdivision data: 47 Japanese prefectures, 36 Indian states and territories, over 100 UK counties and council areas, and keeping them spelled the way locals spell them. That data is the feature, not the garnish.
-
Label layout is localization, not decoration A US label reads city, state, ZIP. A German label reads postal code, city. A Japanese label reads postal code, prefecture, city, street. Getting the preview right for each country caught more real mistakes in testing than the pattern checks did, because people recognize their own address layout instantly.
-
AI is a better second opinion than gatekeeper When Claude was the validator, every answer needed a trust judgment. When local checks pass first and Claude only suggests improvements, its failure modes stop mattering: a bad suggestion is ignorable, and a good one is a bonus. The product decision is where the model sits in the flow, not how clever the prompt is.
Tools Used
Tech Stack
Built without frameworks or build tools: vanilla JavaScript, a country config table, and an optional Claude review.
Keep exploring
More from the site
Head back to the projects page.