If you want JSON output, then there is httpbin.
curl https://httpbin.org/ip
returns {
"origin" : "192.168.0.1"
}
It also supports getting the user agent [0] and headers [1], among other things.[0] https://httpbin.org/user-agent [1] https://httpbin.org/headers