Skip to content

Look up IP geolocation with curl

To geolocate an IP address with curl, append ?ip= to any ipconfig.io endpoint — for example curl ipconfig.io/json?ip=1.1.1.1. It returns what the service knows about that address: country, city, coordinates, time zone, and the owning network. You can look up any IP, not just your own.

Maintained by the ipconfig.io team · Reviewed 17 June 2026

How do I geolocate one IP address?

Request the /json endpoint with the ?ip= parameter and you get the full record in one call:

sh
curl ipconfig.io/json?ip=1.1.1.1
json
{
  "ip": "1.1.1.1",
  "ip_decimal": 16843009,
  "country": "Australia",
  "country_iso": "AU",
  "country_eu": false,
  "asn": "AS13335",
  "asn_org": "Cloudflare, Inc.",
  "hostname": "one.one.one.one"
}

How accurate is IP geolocation?

Country-level IP geolocation is highly accurate, but city-level is only best-effort. MaxMind, whose GeoLite2 data powers ipconfig.io, estimates its databases identify the country with about 99.8% accuracy, but only about 66% accuracy within 50 km of the correct city for US addresses (MaxMind geolocation accuracy; city accuracy varies by country). The reasons matter:

  • It is database-derived, not GPS. Coordinates are the center of an estimated area, not a device's real position.
  • Anycast and infrastructure IPs have no single location. Addresses like 1.1.1.1 are announced from many cities at once, so they often return no city.
  • Country and ASN are the reliable fields. Treat city and coordinates as a hint, never as a precise location.

How do I get just one geolocation field?

Use the plain-text endpoints — they skip the JSON entirely and return a single value, ideal for scripts:

sh
curl ipconfig.io/country?ip=8.8.8.8        # United States
curl ipconfig.io/coordinates?ip=8.8.8.8    # 37.751000,-97.822000
curl ipconfig.io/asn-org?ip=8.8.8.8        # Google LLC

How do I parse the geolocation JSON with jq?

Pipe /json into jq to pull out exactly the fields you need:

sh
# country and network in one line
curl -s ipconfig.io/json?ip=1.1.1.1 | jq -r '"\(.country) — \(.asn_org)"'
# Australia — Cloudflare, Inc.

# just the coordinates
curl -s ipconfig.io/json?ip=8.8.8.8 | jq -r '"\(.latitude),\(.longitude)"'

How do I geolocate a list of IP addresses?

A shell loop is enough for a quick batch — one request per address:

sh
for ip in 1.1.1.1 8.8.8.8 9.9.9.9; do
  echo "$ip -> $(curl -s ipconfig.io/country?ip=$ip)"
done
1.1.1.1 -> Australia
8.8.8.8 -> United States
9.9.9.9 -> United States

Can I stop my own IP from revealing my location?

Yes — route your traffic through a VPN, which replaces your IP (and the approximate location and ISP it leaks) with the VPN server's. Run curl ipconfig.io with and without the VPN connected and you'll see the country, city, and ASN change. We point to Proton VPN — Swiss, independently audited, no-logs — as a privacy-respecting option. (Affiliate link; it helps keep ipconfig.io free. Use any no-logs provider you trust.)

Frequently asked questions

How do I look up the location of an IP with curl? Append ?ip= to any endpoint: curl ipconfig.io/json?ip=1.1.1.1 for the full record, or curl ipconfig.io/country?ip=1.1.1.1 for just the country.

How accurate is IP geolocation? Country is ~99.8% accurate (MaxMind); city is best-effort — about 66% within 50 km for US addresses — because it's database-derived, not GPS.

Can I find an exact street address from an IP? No. IP geolocation resolves to an approximate city or region at best, never a street address or a specific person.

Fields you can read

Every field — country, city, region_name, latitude, time_zone, asn, and the rest — is documented in the ipconfig.io API reference. New to networks? Read what an ASN is and how to find yours.

Geolocation by MaxMind GeoLite2. No tracking, no keys.