ip location database(JSON / CSV)

Autor:Lisa Farrell · 2025-07-29

The IP Geolocation Database maps contiguous IP ranges (ip_from~ip_to) to country/region, administrative subdivision, city, and latitude/longitude. Typical use cases include geo-based routing, compliance & risk control, nearest routing, and operational analytics. Data is exported separately for IPv6 and IPv4 with identical columns and file formats.

Schema (Column Definitions)

  • ip_from VARCHAR(39) NOT NULL: Start IP (supports IPv4/IPv6).
  • ip_to VARCHAR(39) NOT NULL: End IP (supports IPv4/IPv6).
  • country_code CHAR(2): ISO 3166-1 Alpha-2 (e.g., US, CN).
  • region VARCHAR(100): State/Province/First-level subdivision.
  • city VARCHAR(100): City name.
  • latitude DECIMAL(9,5): Latitude.
  • longitude DECIMAL(9,5): Longitude.
DDL (MySQL Example)
CREATE TABLE geoip_ranges (
  ip_from      VARCHAR(39)  NOT NULL,
  ip_to        VARCHAR(39)  NOT NULL,
  country_code CHAR(2),
  region       VARCHAR(100),
  city         VARCHAR(100),
  latitude     DECIMAL(9,5),
  longitude    DECIMAL(9,5),
  PRIMARY KEY (ip_from, ip_to)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Downloads

For each stack (IPv6 / IPv4) we provide three formats: JSON (.gz), CSV (.gz), and SQL (.gz).

Source Type Format Download Notes
IPIN IPv6 JSON (.gz) Download IPv6 ranges → geodata (JSON array).
IPIN IPv6 CSV (.gz) Download Standard comma-delimited with header; ETL/spreadsheet-friendly.
IPIN IPv6 SQL (.gz) Download Includes CREATE TABLE + bulk INSERT; direct import to MySQL.
IPIN IPv4 JSON (.gz) Download IPv4 ranges → geodata (JSON array).
IPIN IPv4 CSV (.gz) Download Standard comma-delimited with header; ETL/spreadsheet-friendly.
IPIN IPv4 SQL (.gz) Download Includes CREATE TABLE + bulk INSERT; direct import to MySQL.

Note: all downloads are .gz archives. You can extract with gunzip, or stream them directly in your program.

Quick CLI Downloads

curl

# IPv6
curl -fL -OJ 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.json.gz'
curl -fL -OJ 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.csv.gz'
curl -fL -OJ 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.sql.gz'

# IPv4
curl -fL -OJ 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.json.gz'
curl -fL -OJ 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.csv.gz'
curl -fL -OJ 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.sql.gz'

wget

# Use server-provided filenames (--content-disposition)
# IPv6
wget --content-disposition 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.json.gz'
wget --content-disposition 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.csv.gz'
wget --content-disposition 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.sql.gz'

# IPv4
wget --content-disposition 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.json.gz'
wget --content-disposition 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.csv.gz'
wget --content-disposition 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.sql.gz'

# Specify filename + resume
wget -c -O ipv6_ip_location.json.gz 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.json.gz'
wget -c -O ipv6_ip_location.csv.gz  'https://ipin.io/exports/20251028_204109/ipv6_ip_location.csv.gz'
wget -c -O ipv6_ip_location.sql.gz  'https://ipin.io/exports/20251028_204109/ipv6_ip_location.sql.gz'
wget -c -O ipv4_ip_location.json.gz 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.json.gz'
wget -c -O ipv4_ip_location.csv.gz  'https://ipin.io/exports/20251028_204109/ipv4_ip_location.csv.gz'
wget -c -O ipv4_ip_location.sql.gz  'https://ipin.io/exports/20251028_204109/ipv4_ip_location.sql.gz'

aria2c (multi-connection)

# IPv6
aria2c -x16 -s16 -k1M -o ipv6_ip_location.json.gz 'https://ipin.io/exports/20251028_204109/ipv6_ip_location.json.gz'
aria2c -x16 -s16 -k1M -o ipv6_ip_location.csv.gz  'https://ipin.io/exports/20251028_204109/ipv6_ip_location.csv.gz'
aria2c -x16 -s16 -k1M -o ipv6_ip_location.sql.gz  'https://ipin.io/exports/20251028_204109/ipv6_ip_location.sql.gz'

# IPv4
aria2c -x16 -s16 -k1M -o ipv4_ip_location.json.gz 'https://ipin.io/exports/20251028_204109/ipv4_ip_location.json.gz'
aria2c -x16 -s16 -k1M -o ipv4_ip_location.csv.gz  'https://ipin.io/exports/20251028_204109/ipv4_ip_location.csv.gz'
aria2c -x16 -s16 -k1M -o ipv4_ip_location.sql.gz  'https://ipin.io/exports/20251028_204109/ipv4_ip_location.sql.gz'

PowerShell

# IPv6
Invoke-WebRequest -Uri "https://ipin.io/exports/20251028_204109/ipv6_ip_location.json.gz" -OutFile "ipv6_ip_location.json.gz"
Invoke-WebRequest -Uri "https://ipin.io/exports/20251028_204109/ipv6_ip_location.csv.gz"  -OutFile "ipv6_ip_location.csv.gz"
Invoke-WebRequest -Uri "https://ipin.io/exports/20251028_204109/ipv6_ip_location.sql.gz"  -OutFile "ipv6_ip_location.sql.gz"

# IPv4
Invoke-WebRequest -Uri "https://ipin.io/exports/20251028_204109/ipv4_ip_location.json.gz" -OutFile "ipv4_ip_location.json.gz"
Invoke-WebRequest -Uri "https://ipin.io/exports/20251028_204109/ipv4_ip_location.csv.gz"  -OutFile "ipv4_ip_location.csv.gz"
Invoke-WebRequest -Uri "https://ipin.io/exports/20251028_204109/ipv4_ip_location.sql.gz"  -OutFile "ipv4_ip_location.sql.gz"

Tip: the downloads are .gz archives. Use gunzip or an extractor to decompress; you can also stream them directly in your program.

Format Reference

JSON

Array of objects; each item includes ip_from, ip_to, country_code, region, city, latitude, and longitude.

[
  {
    "ip_from": "2400:cb00::",
    "ip_to":   "2400:cb00:ffff:ffff:ffff:ffff:ffff:ffff",
    "country_code": "US",
    "region": "California",
    "city": "Los Angeles",
    "latitude": 34.05460,
    "longitude": -118.24400
  }
]
CSV

Header row present; fields with commas/quotes are escaped per RFC 4180.

ip_from,ip_to,country_code,region,city,latitude,longitude
1.0.0.0,1.0.0.255,AU,Queensland,South Brisbane,-27.47480,153.01700
SQL

Contains CREATE TABLE and bulk INSERT statements, suitable for direct import into MySQL.

-- See DDL above
INSERT INTO geoip_ranges
(ip_from, ip_to, country_code, region, city, latitude, longitude) VALUES
('1.0.0.0','1.0.0.255','AU','Queensland','South Brisbane',-27.47480,153.01700);

How to Use (Quick Start)

  1. Pick the IPv6 or IPv4 JSON / CSV / SQL file you need and download it.
  2. Decompress and load into your database (or parse directly in your program).
  3. Apply routing/compliance policies by country, region, city, or coordinates; for proximity-based routing, use distance as a coarse heuristic.
  4. Schedule periodic full refreshes (e.g., daily/weekly) to keep the dataset up to date.

Additional Notes

  • IPv6 and IPv4 share the same column definitions; only the covered address space differs.
  • Coordinates and subdivisions provide approximate location, not precise addresses; follow privacy and compliance requirements.
  • For high-performance lookups, convert IPv4 to 32-bit integer ranges; for IPv6, use prefix trees/interval trees or specialized indexes.