world – Look up DNS country codes#

This package provides a mapping between top-level domain names and their two letter ISO 3166 country codes. This script also knows about many non-geographic, generic, USA-centric, historical, common usage, and reserved top-level domains.

Both a command line script called world and a library called world are available. The latter can be imported into your Python code for whatever application you want.

This script takes a list of Internet top-level domain names and prints out where in the world those domains originate from. For example:

$ world tz us
tz originates from Tanzania, United Republic of
us originates from United States of America (the)

Reverse look ups are also supported:

$ world -r united
Matches for "united":
  ae: United Arab Emirates (the)
  gb: United Kingdom of Great Britain and Northern Ireland (the)
  tz: Tanzania, United Republic of
  uk: United Kingdom (common practice)
  um: United States Minor Outlying Islands (the)
  us: United States of America (the)

Only two-letter country codes are supported, since these are the only ones that were freely available from the ISO 3166 standard. However, as of 2015-01-09, even these are no longer freely available in a machine readable format.


world requires Python 3.8 or newer.


A simple guide to using the library is available, along with a detailed API reference.

Project details#

You can install it with pip:

% pip install world

You can grab the latest development copy of the code using git. The main repository is hosted on GitLab. If you have git installed, you can grab your own branch of the code like this:

$ git clone

You can contact the author via

Table of Contents and Index#