In this tutorial, We will learn how to get client machine IP addresses using javascript code. JavaScript works with third-party applications to fetch the IP addresses.


Example:

<!DOCTYPE html>
<html>
    <head>
        <title>how to get client ip address using javascript?</title>
    </head>
    <body>  
        <h3>IP Address of user is:</h3> 
        <p style="color: red;"><strong id="ip"></strong></p> 

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script type="text/javascript">

            $.getJSON("https://api.ipify.org?format=json", function (data) {

                $("#ip").html(data.ip);

            })

        </script> 
    </body>
</html>


Output:

157.34.7.226


Thanks, May this example will help you.