HackMyIP
← back to sheets

Curl What Is My IP: One-Liners, JSON Output, and Every Endpoint Compared (2026)

~/sheets/curl-what-is-my-ip.md
1

The Short Answer

2

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.

3

The One-Liner

4
curl hackmyip.com
5

That 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:

6
curl -s hackmyip.com/json | grep -o '"ip": *"[^"]*"'
7

How It Detects the Terminal

8

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.

9

Other Clients

10

wget

11
wget -qO- hackmyip.com
12

PowerShell (Windows)

13
(Invoke-WebRequest hackmyip.com/json).Content | ConvertFrom-Json
14

Python

15
python3 -c "import urllib.request,json;print(json.load(urllib.request.urlopen('https://hackmyip.com/json')))"
16

Every Command-Line IP Endpoint Compared

17

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.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
Endpointcurl outputJSON variantHTTPSIPv4/IPv6Run by / policy (as stated)
hackmyip.com (this site)IP + city + network, IP on its own line/json (minimal), /api/ip (full)YesDual-stackFree privacy toolkit, no key
ifconfig.mePlain IP, no trailing newline/all.jsonYesDual-stackOperator not stated on site
icanhazip.comPlain IP + newlineNone (plaintext only)YesDual-stack; ipv4. / ipv6. subdomainsCloudflare (since 2021, per its creator)
api.ipify.orgPlain IP?format=jsonYesIPv4 only; api64. dual, api6. v6-onlyipify project; states no usage limit
ifconfig.coPlain IP + newline (HTML in browsers)/json (full geo)YesDual-stackOpen-source echoip; asks max 1 request/minute
checkip.amazonaws.comPlain IP + newlineNoneYesIPv4 onlyAmazon; no policy published
ipinfo.io/ipPlain IP/json (geo)YesIPv4 onlyIPinfo; free limit not stated, pushes token signup
ident.mePlain IP/json (geo + ASN)YesDual-stack; 4. / 6. subdomainsIndependent, running since 2012; asks for an email above 500 req/s
ip.mePlain IP + newline (HTML in browsers)None foundYesDual-stackProton (per its own about page)
wtfismyip.com/textPlain IP + newline/jsonYesDual-stackIndependent; max 1 request/minute, commercial use prohibited
ipecho.net/plainPlain IP, no trailing newlineNoneYesDual-stackOperator not named; asks callers to cache the result
checkip.dyndns.orgHTML, needs parsing (not clean plaintext)NoneYesIPv4 onlyNot stated on the response
ip-api.com/line/?fields=queryPlain IP (HTTP only)/json (main product)No — HTTPS returns 403 on the free tierIPv4 only45 requests/minute, non-commercial only
136

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.

137

Get Your IP as JSON (myip json)

138

When a script needs structured output instead of bare text, these all returned valid JSON on the same test date:

139
curl hackmyip.com/json              # ip, city, country, asn, org
140
curl "https://api.ipify.org?format=json" # {"ip":"..."} and nothing else
141
curl ifconfig.co/json # full geo: country, city, lat/lon, ASN
142
curl ident.me/json # geo + ASN
143
curl https://hackmyip.com/api/ip # full enrichment: geo, ISP, VPN/datacenter flags
144

To 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.

145

IPv4 or IPv6: Why the Same Command Gives Different Answers

146

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:

147

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.

148

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.

149

No HTTP? Get Your IP Over DNS

150

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):

151
# OpenDNS
152
dig +short myip.opendns.com @resolver1.opendns.com
153
# Google
154
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
155
# Cloudflare (CHAOS class)
156
dig +short CH TXT whoami.cloudflare @1.1.1.1
157
# Windows without dig
158
nslookup myip.opendns.com resolver1.opendns.com
159

The 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.

160

Script Gotchas That Bite

161

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.

162

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.

163

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.

164

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.

165

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.

166

When You Want More Than the IP

167

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'.

168

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.

169

Frequently Asked Questions

170

How do I check my IP address from the command line?

171

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.

172

What does "curl what is my IP" return?

173

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.

174

How do I get my IP as JSON from curl?

175

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.

176

Does this work on Windows?

177

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.

178

Is it free and does it require an account?

179

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.

180

Why does curl show a different IP than ipconfig or my router?

181

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.

182

Why does curl ifconfig.me suddenly return an IPv6 address?

183

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.

184

Can I get my public IP without HTTP at all?

185

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.

186
Last updated: July 12, 2026