Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to encode data into a user token that describes the user's Country, State, and city. I understand that different descriptors apply to different government hierarchies, but am looking for a standard of some type that has already sorted this out.

What ISO standard, binary format, etc is best at describing a user who may be from any country?

share|improve this question
Similar, might help:… – Silviu Burcea Feb 7 '14 at 17:53
There's which might be of some use. It doesn't define an address format, but it includes standard country codes. – FrustratedWithFormsDesigner Feb 7 '14 at 17:54
Latitude and longitude? – Eric Feb 7 '14 at 18:04

Bluntly, there isn't any one standard. Within the US, there are differing notations for states, counties, and regions (zip codes, area codes, metropolitan regions, etc.). While the US does have a standardized address format, even that is highly subject to variations. Also, address standards change regularly. Before the age of the internet, mailing a letter could be done without a zip code (because they hadn't been invented at the time) and you used a 3 letter abbreviation for most states.

Canada has a similar addressing scheme to the US. However, the postal codes in Canada are 6 or 7 digits. Including a space after the 3rd character of the postal code may appear to be the same region, but it isn't. I have also heard rumors of Canada moving to an 8 digit postal code.

Almost every country has an online guide from their official postal service with detailed information about acceptable address formats.

Google, ESRI, and other map data providers have come up with varying ways to associate an address with a lat/long pair. Google uses KML (a specific standard of XML used for addresses). They break an address into a street number, street name, lat/long, and several political hierarchies. You will find that in some countries, the political divisions can be 7 or 8 layers deep (maybe more since the last time I did research into this area).

If you are looking at what you need to store in a database for your customers, follow the US address format with several additional address lines (I typically store a minimum of 3 address lines for international addresses), a city, a state or province, a postal code (international needs to allow for at least 15 characters, digits and alpha), and a country. I have started to include lat/long recently as addresses can change without warning.

There are ISO standards for country code which a quick search will turn up a bunch of links. Beyond that, you are pretty much on your own for formatting though.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.