Get your public IP with curl
From a terminal, ipthing.net returns JSON: your public IP, approximate location, the headers you sent, and TLS details. Browsers (and clients that explicitly prefer text/html) still get HTML on the same URL.
How do I get my public IP with curl?
curl https://ipthing.net
Non-browser clients receive JSON. For the address alone as plain text:
curl -s https://ipthing.net/ip
Or extract it from JSON:
curl -s https://ipthing.net | jq -r .IPAddr
Field names are PascalCase and match the labels on the HTML page. IPAddr is the TCP or QUIC peer — not X-Forwarded-For.
How do I check IPv4 or IPv6 with curl?
curl -4 https://ipthing.net curl -6 https://ipthing.net curl https://ipv4.ipthing.net curl https://ipv6.ipthing.net
Without -4 or -6, curl uses whichever address family DNS prefers. The ipv4. / ipv6. hosts are single-family DNS names for browsers and tools that cannot pass those flags. More detail: IPv6 address check.
Why does curl get JSON instead of HTML?
A browser User-Agent (Mozilla, AppleWebKit, Gecko, …) receives HTML, as does a non-browser client with Accept: text/html preferred over JSON. Typical curl sends Accept: */* and gets pretty-printed JSON.
HTTP without TLS
curl http://ipthing.net
Plain HTTP stays available on purpose, for scripts and images that have no CA bundle. There is no redirect to HTTPS.
Example JSON
{
"IPAddr": "203.0.113.50",
"IPFamily": "ipv4",
"Country": "US",
"Org": "AS65536 Example ISP",
"UserAgent": "curl/8.0.0",
"Proto": "HTTP/2.0",
"TLSVersion": "TLS 1.3",
"JA4": "t13d…",
"XFF": ""
}
Related: request headers and TLS / JA3 / JA4. Live traffic mix: stats.ipthing.net.