Open Country Codes: ISO 3166 country names and Alpha-2 country codes in HTML, Python, JavaScript, ActionScript, Flex, JSON, and XML

Introducing Open Country Codes: easy to use ISO 3166 country codes for your apps.

Why are some things just much harder than they need to be? Finding a current, easy-to-use data source for populating a country selection box, for example.

Most of the clean country data out on the web is second-hand, having at one point in time been scraped and tediously hand-converted from the International Organization for Standardization (ISO)'s page of English country names and code elements.

That list "states the country names (official short names in English) in alphabetical order as given in ISO 3166-1 and the corresponding ISO 3166-1-alpha-2 code elements" of 246 countries and is free to use.

Unfortunately, it's an HTML table. Which means that you have some manual data massaging to do if you want to use it. Sucks big time.

ISO also sells the ISO 3166 "database" for about $148 USD. And it comes in -- get this -- Microsoft Access format. I bet we've all got a copy laying around somewhere, right? Oh wait, it's not 1999! So they want to charge you about 60 cents per country name? Not acceptable.

So what's a developer to do? Scrape the site? Write his one-line regular expression to pull out the data? Solve his own problem and move on?

Nah, let's make things better so that other developers don't lose precious time having to jump through ridiculous hoops! :)

Et, voilà, I present to you Open Country Codes.

This simple and deliberately unstyled little app gives you the ISO 3166-1 and ISO 3166-1-alpha-2 country name and country code lists in a variety of ready-to-use formats. There's an HTML country list selection box that you can drop into your page, and pure data structures in Python, JavaScript, ActionScript and a CountryComboBox component for Flex.

There are also JSON and XML feeds that you can use in your applications.

The application pulls in a fresh copy of the list every day and the code samples are dynamically generated.

I hope you find this useful. If you have any suggestions for improving it, please leave me a comment here.

Comments