Curl What Is My IP: One-Liners, JSON Output, and Every Endpoint Compared (2026)
The Short Answer
To see your public IP address from a terminal, run curl hackmyip.com. It prints your IP, city, country, and network (ASN + ISP) as clean colored text. No install beyond curl, which already ships on macOS, Linux, and Windows 10/11. No signup, no API key. For just the raw fields as JSON, run curl hackmyip.com/json. Open the web version of this check if you prefer a browser.
The One-Liner
curl hackmyip.comThat returns a short, readable block: your IP on its own line, then location and network. Because the IP is on its own line, you can pipe it. To grab just the address:
curl -s hackmyip.com/json | grep -o '"ip": *"[^"]*"'How It Detects the Terminal
When you hit hackmyip.com with curl, wget, or another command-line client, the site looks at your User-Agent and serves plain text instead of the HTML page. A browser still gets the full site. There is no separate endpoint to remember — the same root URL adapts to whoever is asking. If you want to force the machine-readable shape from anywhere, use curl hackmyip.com/json.
Other Clients
wget
wget -qO- hackmyip.comPowerShell (Windows)
(Invoke-WebRequest hackmyip.com/json).Content | ConvertFrom-JsonPython
python3 -c "import urllib.request,json;print(json.load(urllib.request.urlopen('https://hackmyip.com/json')))"Every Command-Line IP Endpoint Compared
These are the "what is my IP" endpoints developers actually use in scripts. Every row was tested live with curl on July 12, 2026, and all working endpoints returned the same address in a cross-check. Output details are from those live responses; operator and policy notes come from each service's own site on the same date. Endpoints change hands and policies drift, so re-test before you build anything critical on one. IPv4/IPv6 support reflects each host's published DNS records (A and AAAA); which family you actually get depends on your own network — see the next section.
| Endpoint | curl output | JSON variant | HTTPS | IPv4/IPv6 | Run by / policy (as stated) |
|---|---|---|---|---|---|
| hackmyip.com (this site) | IP + city + network, IP on its own line | /json (minimal), /api/ip (full) | Yes | Dual-stack | Free privacy toolkit, no key |
| ifconfig.me | Plain IP, no trailing newline | /all.json | Yes | Dual-stack | Operator not stated on site |
| icanhazip.com | Plain IP + newline | None (plaintext only) | Yes | Dual-stack; ipv4. / ipv6. subdomains | Cloudflare (since 2021, per its creator) |
| api.ipify.org | Plain IP | ?format=json | Yes | IPv4 only; api64. dual, api6. v6-only | ipify project; states no usage limit |
| ifconfig.co | Plain IP + newline (HTML in browsers) | /json (full geo) | Yes | Dual-stack | Open-source echoip; asks max 1 request/minute |
| checkip.amazonaws.com | Plain IP + newline | None | Yes | IPv4 only | Amazon; no policy published |
| ipinfo.io/ip | Plain IP | /json (geo) | Yes | IPv4 only | IPinfo; free limit not stated, pushes token signup |
| ident.me | Plain IP | /json (geo + ASN) | Yes | Dual-stack; 4. / 6. subdomains | Independent, running since 2012; asks for an email above 500 req/s |
| ip.me | Plain IP + newline (HTML in browsers) | None found | Yes | Dual-stack | Proton (per its own about page) |
| wtfismyip.com/text | Plain IP + newline | /json | Yes | Dual-stack | Independent; max 1 request/minute, commercial use prohibited |
| ipecho.net/plain | Plain IP, no trailing newline | None | Yes | Dual-stack | Operator not named; asks callers to cache the result |
| checkip.dyndns.org | HTML, needs parsing (not clean plaintext) | None | Yes | IPv4 only | Not stated on the response |
| ip-api.com/line/?fields=query | Plain IP (HTTP only) | /json (main product) | No — HTTPS returns 403 on the free tier | IPv4 only | 45 requests/minute, non-commercial only |
Two of those rows break scripts in ways guides rarely mention: checkip.dyndns.org returns an HTML page, not plaintext, so it needs grep or sed before you can use the value; and calling ip-api.com over https:// on the free tier returns a 403 error page instead of your IP (verified July 12, 2026) — its plaintext endpoint only works over plain HTTP.
Get Your IP as JSON (myip json)
When a script needs structured output instead of bare text, these all returned valid JSON on the same test date:
curl hackmyip.com/json # ip, city, country, asn, orgTo extract just the address with jq: curl -s hackmyip.com/json | jq -r .ip. If you want the smallest possible JSON payload, ipify with ?format=json returns only the ip field; if you want the most data per call with no key, hackmyip.com/api/ip adds privacy classification (VPN, proxy, datacenter) on top of geolocation — see the free privacy API guide.
IPv4 or IPv6: Why the Same Command Gives Different Answers
A common surprise: curl ifconfig.me works for months, then one day starts printing an IPv6 address. The endpoint did not change — your network did. Dual-stack services publish both A (IPv4) and AAAA (IPv6) DNS records, and once your machine gains working IPv6, curl usually prefers it. Three ways to control which family you get:
curl -4 ifconfig.me forces IPv4 and curl -6 ifconfig.me forces IPv6 on any dual-stack endpoint. Or use family-locked hostnames: ipv4.icanhazip.com / ipv6.icanhazip.com, api.ipify.org (always IPv4) / api6.ipify.org (always IPv6) / api64.ipify.org (either), and 4.ident.me / 6.ident.me.
The reverse confusion is just as common: curl ipv6.icanhazip.com failing with could not resolve host does not mean the endpoint is dead. That hostname publishes only AAAA records, so on an IPv4-only network the lookup finds no usable address and curl reports a resolution failure. The error means your network has no IPv6 — the service is fine. You can confirm what your network supports with the IPv6 tool or by comparing curl -4 and curl -6 output.
No HTTP? Get Your IP Over DNS
You can skip HTTP entirely and ask a DNS resolver to echo your source address back. These work where outbound HTTP is blocked, and a DNS round-trip is typically faster than a TLS handshake (each method re-verified July 2026):
# OpenDNSThe mechanism: you send the query directly to that provider's resolver (the part after @), and it answers with the address the query came from — which is your public IP. Note these return the address of whichever family the query traveled over, same as the HTTP methods.
Script Gotchas That Bite
Trailing newlines are inconsistent. ifconfig.me and ipecho.net return the bare IP with no trailing newline; icanhazip, ifconfig.co, Amazon, ip.me, and wtfismyip append one. If you capture output with command substitution and compare strings, that difference matters — normalize with tr -d '[:space:]' if you switch endpoints.
Browsers are not a valid test. ifconfig.co and ip.me sniff the User-Agent and serve a full HTML page to browsers while giving curl plaintext. Pasting the URL into a browser to check what your script will receive misleads you — test with curl.
Respect the stated limits and cache. ifconfig.co and wtfismyip.com both ask for at most 1 request per minute, and wtfismyip prohibits commercial use. Your public IP rarely changes minute to minute; a cron script that caches the last value and checks every few minutes is friendlier and more reliable than hammering any single endpoint.
Pin the IP family in automation. If a monitoring script stores your IP and alerts on change, a dual-stack endpoint can flip between IPv4 and IPv6 as routing changes and fire false alerts. Use curl -4, or a family-locked hostname, so the answer stays comparable over time.
Endpoints change hands. Operators churn: icanhazip has been run by Cloudflare since 2021, ip.me is run by Proton, and the OpenDNS resolvers now identify as Cisco infrastructure. Nothing above has a contractual SLA. For anything critical, query two endpoints and reconcile, or use your own infrastructure.
When You Want More Than the IP
The terminal one-liner is deliberately short. For richer data there is a free public API with no key: see the full API docs. For example, curl https://hackmyip.com/api/ip returns geolocation, ISP, ASN, and a VPN/proxy/datacenter classification. To look up a different address, use curl 'https://hackmyip.com/api/lookup?ip=8.8.8.8'.
Browser-side privacy checks that a terminal cannot do — like detecting whether your VPN is leaking — live on the site: run a DNS leak test or a WebRTC leak test, or check whether your IP looks like a proxy or VPN.
Frequently Asked Questions
How do I check my IP address from the command line?
Run curl hackmyip.com in any terminal. It prints your public IP plus your city, country, and network. curl is preinstalled on macOS, Linux, and Windows 10 and 11. For machine-readable output, use curl hackmyip.com/json.
What does "curl what is my IP" return?
It returns your public IP address as seen by the internet, along with your approximate location (city, region, country) and your network (ASN and ISP). The plain IP is on its own line so you can pipe or copy it. There is no signup and no API key.
How do I get my IP as JSON from curl?
Run curl hackmyip.com/json. It returns a small JSON object with ip, city, country, asn, and org. For richer fields including VPN/proxy detection, use the free no-key API at curl https://hackmyip.com/api/ip.
Does this work on Windows?
Yes. Windows 10 and 11 ship curl, so curl hackmyip.com works in Command Prompt and PowerShell. You can also use (Invoke-WebRequest hackmyip.com/json).Content in PowerShell for the JSON form.
Is it free and does it require an account?
Yes, it is free, and no. There is no signup, no API key, and no rate-limit registration for the basic IP check. HackMyIP is a free privacy toolkit; the terminal one-liner and the JSON endpoint are open to anyone.
Why does curl show a different IP than ipconfig or my router?
Local tools like ipconfig, ifconfig, and your router admin page show your private LAN address (usually 192.168.x.x or 10.x.x.x). The curl services see your connection from the other side — the public address your ISP assigned after NAT, which is what every website and server on the internet sees. Both answers are correct; they are different addresses at different network layers. See public vs private IP for the full picture.
Why does curl ifconfig.me suddenly return an IPv6 address?
The endpoint did not change — your network gained working IPv6, and curl prefers it on dual-stack hosts. Force a family with curl -4 or curl -6, or use family-locked hostnames like ipv4.icanhazip.com or 4.ident.me so the answer stays stable in scripts.
Can I get my public IP without HTTP at all?
Yes, over DNS. Run dig +short myip.opendns.com @resolver1.opendns.com and the OpenDNS resolver echoes back the address your query came from. Google (dig TXT +short o-o.myaddr.l.google.com @ns1.google.com) and Cloudflare (dig +short CH TXT whoami.cloudflare @1.1.1.1) offer the same trick. DNS lookups work where outbound HTTP is blocked and are typically faster than a TLS handshake.