GeoIP2 and GeoLite City and Country Databases

Determine the country, subdivisions (regions), city, and postal code associated with IPv4 and IPv6 addresses worldwide.

Terms and pricing for the GeoIP2 City and GeoIP2 Country databases may be found on our product pages:

IP Geolocation Usage

IP geolocation is inherently imprecise. Locations are often near the center of the population. Any location provided by a GeoIP database should not be used to identify a particular address or household.

Data Privacy

To comply with data privacy regulations, please monitor our Do Not Sell My Personal Information Requests page (login required) for IP addresses and networks that should not be used for advertising or marketing purposes. You can automate retrieval of this list using our privacy exclusions API.

Binary Databases

Binary databases make use of the MaxMind DB file format. MaxMind provides official API clients in the language listed below. The following API clients are open source and licensed under the Apache License, Version 2.0.

You can also use the mmdbinspect tool (in beta), a command line interface built with Go, to look up one or more IPs from one or more MMDB databases and receive output in a parsable JSON format.

CSV Databases

In addition to our MaxMind DB binary format, we also offer GeoIP2 and GeoLite2 databases in a CSV format suitable for importing into a SQL database. The CSV files are shipped as a single zip file.

The zip file itself is named  {GeoIP2,GeoLite2}-{City,Country}-CSV_{YYYYMMDD}.zip. The downloaded zip file contains a single directory which in turn contains several files. That directory is named  {GeoIP2,GeoLite2}-{City,Country}-CSV_{YYYYMMDD}.

The downloaded .zip file contains a single directory which in turn contains 13 files:

Filename

Description

COPYRIGHT.txt

Copyright statement

LICENSE.txt

End user license

README.txt

Information file

{GeoIP2,GeoLite2}-{City,Country}-Blocks-IPv4.csv

CSV file containing data on IPv4 addresses

{GeoIP2,GeoLite2}-{City,Country}-Blocks-IPv6.csv

CSV file containing data on IPv6 addresses

{GeoIP2,GeoLite2}-{City,Country}-Locations-{locale}.csv

Eight CSV files containing data location for each locale code, where {locale} can be “de”, "en", “es”, “fr”, “ja”, “pt-BR”, “ru”, and “zh-CN” .

All the CSV files start with a single header row containing column names. The specific column names and their contents are detailed below. The files are encoded as UTF-8.

Blocks Files

There are two CSV files for network blocks, one each for IPv4 and IPv6 blocks. These files are named {GeoIP2,GeoLite2}-{City,Country}-Blocks-IPv4.csv and {GeoIP2,GeoLite2}-{City,Country}-Blocks-IPv6.csv respectively. An example name would be GeoIP2-City-Blocks-IPv4.csv.

City subset by continent databases blocks files have the same columns as the City database.

NameTypeDescriptionIncluded in...
networkIP network as a stringThis is the IPv4 or IPv6 network in CIDR format such as "2.21.92.0/29" or "2001:4b0::/80". We offer a utility to convert this column to start/end IPs or start/end integers. See the conversion utility section for details.CountryCity
geoname_idintegerA unique identifier for the network's location as specified by GeoNames. This ID can be used to look up the location information in the Location file.CountryCity
registered_country_geoname_idintegerThe registered country is the country in which the ISP has registered the network. This column contains a unique identifier for the network's registered country as specified by GeoNames. This ID can be used to look up the location information in the Location file.CountryCity
represented_country_geoname_idintegerThe represented country is the country which is represented by users of the IP address. For instance, the country represented by an overseas military base. This column contains a unique identifier for the network's registered country as specified by GeoNames. This ID can be used to look up the location information in the Location file.CountryCity
is_anonymous_proxybooleanDeprecated. Please see our GeoIP2 Anonymous IP database to determine whether the IP address is used by an anonymizing service.CountryCity
is_satellite_providerbooleanDeprecated.CountryCity
postal_codestringA postal code close to the user's location. For the following countries, we return partial postal codes with the number of characters indicated below:
  • United States: 5
  • Canada: 3
  • United Kingdom: 2-4
  • Brazil: 5
  • Ireland: 3
  • Japan: 7 (specified for the first 6. The last digit defaults to 1)
  • Netherlands: 4
  • Portugal: 7 (accurate for the first 4. The last 3 often defaults to -001)
  • Singapore: 2
CountryCity
latitude*decimalThe approximate WGS84 latitude of the location associated with the network.CountryCity
longitude*decimalThe approximate WGS84 longitude of the location associated with the network.CountryCity
accuracy_radiusintegerThe radius in kilometers around the specified location where the IP address is likely to be. Learn more about accuracy on our Support Center.CountryCity

* The coordinates are not precise and should not be used to identify a particular street address or household. To better represent a level of accuracy, please include the accuracy_radius when displaying latitude and longitude and make it clear that the coordinates refer to a larger geographical area instead of a precise location.

Locations Files

The zip file includes one location file for each locale code for which data is available. There will always be an "en" file containing a record for every geoname_id used in the blocks files. Files corresponding to other locales will exist and have a record for a geoname_id only if data is available. The other possible locales are "de", "es", "fr", "ja", "pt-BR", "ru", and "zh-CN".

These files are named {GeoIP2,GeoLite2}-{City,Country}-Locations-{locale}.csv. An example name would be GeoIP2-City-Locations-en.csv.

City subset by continent databases blocks files have the same columns as the City database.

NameTypeDescriptionIncluded in...
geoname_idintegerA unique identifier for the a location as specified by GeoNames. This ID can be used as a key for the Location file.CountryCity
locale_codestringThe locale that the names in this row are in. This will always correspond to the locale name of the file.CountryCity
continent_codestring (2)

The continent code for this location. Possible codes are:

  • AF - Africa
  • AN - Antarctica
  • AS - Asia
  • EU - Europe
  • NA - North America
  • OC - Oceania
  • SA - South America
CountryCity
continent_namestringThe continent name for this location in the file's locale.CountryCity
country_iso_codestring (2)A two-character ISO 3166-1 country code for the country associated with the location.CountryCity
country_namestringThe country name for this location in the file's locale.CountryCity
subdivision_1_iso_codestring (1-3)A string of up to three characters containing the region-portion of the ISO 3166-2 code for the first level region associated with the IP address. Some countries have two levels of subdivisions, in which case this is the least specific. For example, in the United Kingdom this will be a country like "England", not a county like "Devon".CountryCity
subdivision_1_namestringThe subdivision name for this location in the file's locale. As with the subdivision code, this is the least specific subdivision for the location.CountryCity
subdivision_2_iso_codestring (1-3)A string of up to three characters containing the region-portion of the ISO 3166-2 code for the second level region associated with the IP address. Some countries have two levels of subdivisions, in which case this is the most specific. For example, in the United Kingdom this will be a a county like "Devon", not a country like "England".CountryCity
subdivision_2_namestringThe subdivision name for this location in the file's locale. As with the subdivision code, this is the most specific subdivision for the location.CountryCity
city_namestringThe city name for this location in the file's locale.CountryCity
metro_codeintegerThe metro code associated with the IP address. These are only available for networks in the US.CountryCity
time_zonestringThe time zone associated with location, as specified by the IANA Time Zone Database, e.g., “America/New_York”.CountryCity
is_in_european_unionbooleanThis is 1 if the country associated with the location is a member state of the European Union. It is 0 otherwise.CountryCity

Returned Values as Database, Map, Dict, or Hash Keys

We strongly discourage you from using a value from any *_name field as a key in a database or map/dict/hash data structure.

These names may change between releases. Instead we recommend using one of the following:

Data objectRecommended key
citygeoname_id
continentcontinent_code
countrycountry_iso_code
postalpostal_code
subdivisionssubdivision_{1,2}_iso_code

Conversion Utility

We've created a small utility program to allow you to convert a GeoIP2 CSV file's representation of IP addresses to another format. You can choose between start/end IP addresses, with the addresses represented as strings or integers.

The program is available from our geoip2-csv-converter GitHub project releases tab.

This page was last updated on June 17, 2021.