LocaleKit Country Format Rules
Address form fields, postal-code regex, calling code and date formats for any country.
How it works
Pick a country to get its address form as an ordered field schema (with required flags and local labels like PIN code or Prefecture), the postal-code pattern with examples and validation, the calling code with basic E.164 normalisation, and date/number formatting examples for the country’s likely locale.
- Address rules come from Google’s Address Data Service (the libaddressinput metadata used by Chromium and Android): fmt gives field order and line breaks (%N name, %O organisation, %A street, %D dependent locality, %C city, %S state/province, %Z postal code, %X sorting code), require/upper list required and upper-cased fields; missing keys fall back to the ZZ defaults.
- Field labels use the country’s zip/state/locality/sublocality name types (e.g. PIN code, Eircode, Prefecture). Tokens not documented in the public metadata (e.g. %T, %F, %L for India) are reported as unmapped rather than guessed.
- Postal-code validation trims, upper-cases and collapses whitespace, then tests the full string against the anchored data pattern ^(?:zip)$.
- Phone: calling code, international and national (trunk) prefixes and possible lengths come from libphonenumber’s PhoneNumberMetadata.xml. Normalisation removes punctuation, handles "+" or the international prefix, otherwise strips the trunk prefix only if libphonenumber defines one (so Italy keeps its leading 0) and prepends the calling code. This is basic: carrier codes, national-prefix-for-parsing rules and number-type validation are not applied.
- Locale: the country’s likely locale is derived with Intl.Locale("und-CC").maximize() (CLDR likely subtags) and used with Intl.DateTimeFormat/NumberFormat on the fixed date 2026-12-31 13:45 UTC so day/month order is unambiguous.
Address and phone metadata change; always accept free-form input as a fallback and never reject an order solely because a postal code or phone number fails a pattern.
Use this tool in an app
These free programs for your browser have this tool built in, next to everything else the task needs.
-
RavingDesk Paper trading & data workspace
Practise trading on paper and chart your data: orders, risk, datasets, analyses, reports.
Related tools
- TimeFair Meeting Planner – Find fair meeting times across time zones, with DST-exact local times and rotation.
How to use LocaleKit Country Format Rules
Get a country's address form fields, postal-code pattern, calling code and date and number formats, and validate a postal code or phone number.
What it is for
Building a checkout, a sign-up form or a CRM import for international customers? Address forms are where things break. Japan writes addresses from big to small, the UK calls the city a "post town", India needs a state and a six-digit PIN code, and some countries have no postal codes at all. LocaleKit gives you, for any of about 250 countries and territories:
- the address form as an ordered field list with local labels, required and upper-case flags;
- the postal-code regex, examples and a validation of the code you enter;
- the calling code and a basic E.164 normalisation of a phone number;
- date and number formats for the country's most likely locale.
The address data comes from Google's Address Data Service (the metadata used by Chromium and Android) and the phone data from libphonenumber. LocaleKit is a reference and a quick check, not a full validator. Phone normalisation is deliberately basic, and the disclaimer is worth taking to heart: never reject a real customer's order just because a pattern fails.
Worked example
Germany, postal code 10115, phone 030 901820:
- Format
%N%n%O%n%A%n%Z %C: name, organisation, street, then postal code and city on one line. Street, postal code and city are required, and the city is upper-cased. - Postal pattern
^(?:\d{5})$, so 10115 is valid. - Phone: spaces removed, trunk prefix "0" dropped, +49 prepended. The national number is 30901820, which gives +4930901820, with a plausible length.
- Locale de-DE:
31.12.2026,31. Dezember 2026,13:45, number1.234.567,891, week starts Monday.
United Kingdom, SW1A 1AAA: invalid. Postcodes end with a digit and two letters. The phone 020 7946 0018 normalises to national number 2079460018 with +44. The locale en-GB shows 31/12/2026.
Japan, 154-0023: valid against ^(?:\d{3}-?\d{4})$. The native format starts with 〒 and the postal code, then the prefecture and street, with organisation and name last. There's also a separate Latin-script format for romanised addresses. Dates look like 2026/12/31.
India: the label is PIN code, State is required with 36 subdivisions listed with ISO codes, and the number format groups lakhs: 12,34,567.891. Three format tokens (%T, %F, %L) are reported as unmapped rather than guessed.
How to read the result
- form.fields: in order, with
linenumbers so you can lay out the form exactly as people write the address. Userequiredfor validation anduppercasefor printing labels. - postal:
used(false if the country has no postal codes), the anchoredpattern,examples, your input's verdict and an official lookup URL. - subdivisions: states, provinces or prefectures, with ISO 3166-2 codes where available. Handy for a dropdown.
- phone: calling code, international and trunk prefixes, possible lengths and step-by-step normalisation.
- locale: formats on the fixed date 31 Dec 2026, 13:45 UTC, so day/month order is unambiguous.
Tips and common mistakes
- Don't use one "ZIP" regex for everyone. Use the per-country pattern and keep a free-text fallback.
- Postal codes are trimmed, upper-cased and space-collapsed before testing, so
sw1a 1aais checked asSW1A 1AA. Normalise the same way in your own code. - Italy keeps its leading 0 in E.164. LocaleKit only strips a trunk prefix where libphonenumber defines one.
- The locale is the likely one (hi-IN for India, de-DE for Germany). In multilingual countries, many users prefer another locale.
- Currency isn't reported, because the browser formatting standard has no country-to-currency mapping and LocaleKit doesn't guess.
FAQ
Which countries don't use postal codes?
LocaleKit shows used: false for them. Hide the field or make it optional instead of forcing a fake value like "00000".
Why are some Indian address lines "unmapped"?
Google's public metadata uses the tokens %T, %F and %L for India without documenting what they mean. LocaleKit reports them instead of inventing labels.
Is the E.164 result safe to store as-is?
It's a basic normalisation: punctuation removed, prefix handled, calling code added. For production, validate with a full libphonenumber implementation or by sending a verification code.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://localekit.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://localekit.usefulweb.site/mcp· tool namelocalekit
Example request
curl -s -X POST https://localekit.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"country":"DE","postalCode":"10115","phone":"030 901820"}'