Convert GeoIP2 data to CSV
When converting GeoIP2 data to CSV makes sense, what the conversion changes, and how to keep IP ranges, postal codes and place names intact in shared files.
Is converting GeoIP2 data to CSV the right move?
Converting GeoIP2 data to CSV fits when you need IP-to-location data in a database, a data warehouse, an analytics pipeline or a script that cannot read the binary MaxMind DB (MMDB) format. It also fits when you want to inspect, filter or join records as ordinary rows. The main benefit is portability: almost any tool that reads delimited text can use the result. The main tradeoff is that you lose the fast built-in address lookup of the MMDB format. You take on range matching, table joins and update handling yourself.
If your only need is to look up individual IP addresses inside an application, keep the MMDB file and use an official reader library. A CSV copy adds steps without adding information.
- CSV is a reasonable choice when:
- You are bulk-loading networks into SQL or a columnar store and will query them with range conditions.
- You need to join location attributes to other datasets by network or by geoname ID.
- Reviewers or auditors need to read the data in a format that is not binary.
- Your target system only accepts delimited text.
- Keep the MMDB format when:
- You do per-request lookups in application code.
- You want updates to be a single file swap rather than a table reload.
- The people receiving the data will open it in a spreadsheet, where the precision and formatting problems described below are most likely.
Three things people mean by "convert"
Searches for a GeoIP2 CSV converter cover three different tasks. They have different inputs and outputs, so identify which one you need first.
- Getting the CSV edition directly: MaxMind distributes many of its databases in a CSV format as well as MMDB. If your subscription or GeoLite account offers it, downloading the CSV edition avoids conversion entirely.
- Changing how networks are written in an existing CSV: MaxMind publishes an open-source command-line converter that reads a GeoIP2 or GeoLite2 blocks CSV and rewrites the network column. Its documentation describes output options such as keeping the CIDR notation or adding start and end IP addresses, integer ranges or hexadecimal ranges. Check the current project documentation for exact options before use.
- Dumping an MMDB file to CSV: this walks the binary database and writes each network and its record as a row. MaxMind's reader libraries can iterate over a database, and third-party tools exist for this. Their output columns and handling of nested fields differ, so check any such tool against its own documentation.
What the conversion actually changes
A correct conversion does not change the underlying facts: which network maps to which country, city, coordinates or accuracy radius. It changes representation in two ways.
First, structure. An MMDB file is a search tree keyed by network, with nested records. The CSV edition flattens this into a blocks file with one row per network, plus a separate locations file keyed by geoname ID. Location files are typically split by language. Place names therefore live in a different table from the network rows, and you must join the two to get a complete picture.
Second, network notation. The blocks file identifies each network in CIDR form, such as 192.0.2.0/24. Range-style conversion adds columns for the first and last address of each network, either as dotted or colon-separated addresses or as integers. Integer columns make range queries possible in systems without native IP types.
Illustrative example, abbreviated, using reserved documentation address ranges rather than real records. Column names and order vary by tool and version, and the location fields are placeholders:
Input (blocks CSV, abbreviated):
network,geoname_id,postal_code,latitude,longitude,accuracy_radius
192.0.2.0/24,<id>,<zip>,<lat>,<lon>,<radius>
Output with address range and integer range added:
network,network_start_ip,network_last_ip,network_start_integer,network_last_integer,geoname_id,...
192.0.2.0/24,192.0.2.0,192.0.2.255,3221225984,3221226239,<id>,...
The example follows from the mechanism. A /24 IPv4 network contains 256 addresses, so it runs from .0 to .255. As an integer, 192.0.2.0 is 192 × 16,777,216 + 2 × 256 = 3,221,225,984, and the last address is 255 higher. When checking a converter's output, verify a few rows the same way. A wrong last address usually indicates an off-by-one or prefix-handling error.
Keep stored values separate from displayed values. A CSV file stores characters exactly as written. Many problems people attribute to the conversion are introduced later, when a spreadsheet or import tool reinterprets those characters as numbers or dates.
Will the CSV stay usable after copying or sharing?
The file itself is plain text and portable. Most risks come from the programs used to open or import it.
- Numeric precision: spreadsheet applications such as Excel keep about 15 significant digits. IPv4 integers fit comfortably. IPv6 integers can run to 39 digits and will be silently rounded if treated as numbers. Import those columns as text, or use a database type that handles 128-bit values.
- Leading zeros: US ZIP codes such as those beginning with 0 lose the zero if a postal code column is read as a number. Import postal codes as text.
- Character encoding: localized place names contain non-ASCII characters. If an application assumes the wrong encoding, names display as garbled symbols even though the stored bytes are correct. Specify UTF-8 explicitly on import.
- Quoting: some place names contain commas. A properly quoted CSV handles this, but naive splitting on commas, or pasting into tools that ignore quotes, shifts columns.
- File size: full city-level block files can be large. Excel's worksheet limit is 1,048,576 rows, so check the row count before opening a file in a spreadsheet. Truncation can happen with only a warning dialog.
- Search: a plain-text search for a specific IP address only finds it if it starts a listed network. Finding which network contains an address requires range logic, either with integer start and end columns or with an IP-aware database function.
Accessibility: raw CSV read as text presents a long stream of comma-separated values, which is hard to follow with a screen reader. The same data opened in a spreadsheet or rendered as a table with header cells is generally easier to navigate, because column headers can be announced. This review did not test any specific screen reader with GeoIP2 CSV files. If accessibility matters for your audience, test with the assistive technology they actually use. For people who only need the conclusions, a short summary table or plain-language description is usually more usable than the full dataset.
Licensing and data handling
Converting the format does not change the license. GeoIP2 and GeoLite2 data are distributed under MaxMind's terms, which govern how the data, including derived CSV files, may be shared or redistributed. Read the terms that apply to your edition before publishing or passing on a converted file.
If you use a web-based converter, your file is sent to someone else's system. Do not assume anything about retention or reuse from the site's appearance. Rely only on its stated policy, or use a local command-line tool.
Checks before relying on the converted file
- Confirm which conversion you performed: CSV edition download, network-column rewrite, or MMDB dump.
- Spot-check several networks by hand, including at least one IPv6 row, to confirm start and end addresses.
- Confirm the row count matches the source blocks file, or that differences are explained.
- Verify that blocks rows join to location rows on geoname ID, and decide how to handle rows with no city-level match.
- Import IP integers, IPv6 values and postal codes as text unless your target system has suitable native types.
- Record the database edition and release date alongside the CSV, since location data is updated regularly and stale copies drift from current data.
Gaps in this review
No confirmed evidence about specific converter versions, performance, file sizes, row counts, pricing or accuracy figures was available for this review. No tools were benchmarked, and no copy-and-paste or screen reader tests were run. The behaviors described above are based on general, verifiable properties of the CSV format, IP addressing and common spreadsheet limits. Confirm tool-specific options and current licensing terms against the official documentation for the version you use.