Nishant Gour
Nishant Gour's Blog


Nishant Gour's Blog

How to get a client IP address using JavaScript?

How to get a client IP address using JavaScript?

Nishant Gour's photo
Nishant Gour
·May 13, 2021·

2 min read

Play this article

In this article, we are to going to see how to get a client IP address using JavaScript.

What is IP address

An IP (Internet Protocol) address can be defined as the address of network hardware. or we can say that an IP address is a combination of numbers that uniquely identifies one’s system. It’s like a house has an address to get mail, just like that your computer has an address to receive the data from the web.

Depending upon javascript alone will not help us, so we will use jQuery as well. JavaScript works with third-party applications to fetch the IP addresses. These third-party application services fetch the IP address and simply return it in three formats, plain text, JSON, and JSONP format.

We can find many application services like ipify and ipinfo. But we are going to use - ipify , one of the most popular tools for finding IP addresses.

So let's see the implementation part:

.html file

!DOCTYPE html>

    <title>Getting Clients IP</title>
        p, h1 {
            color: #175dcf;

            margin-top: 10%;

    <script src=

        /* Add "" statement
           this will communicate with the ipify servers in
           order to retrieve the IP address $.getJSON will
           load JSON-encoded data from the server using a
           GET HTTP request */

                                          function(data) {

            // Setting text of element P with id hashnode

    <center id="content">

       <a href=""> 
<img  src=""/>
        <h1>Nishant's Blog</h1>
        <h3>Your Public IP Adress is Shown Below:</h3>

        <p id="hashnode"></p>





Note: Not Supported for some browsers.

So this is it for today!.

I hope you liked it!. Let's catch up in the next articles and Stay tuned.

If you liked it, Please Support Me

Did you find this article valuable?

Support Nishant Gour by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors