jQuery | serializeArray() with Examples

The serializeArray() is an inbuilt method in jQuery which is used to create a JavaScript array of objects that is ready to be encoded as a JSON string. It operates on a jQuery collection of forms and/or form controls. The controls can be of several types. JSON string is a text and can convert any JavaScript object into JSON, and send JSON to the server.


Parameter: It does not accept any parameter.

Return Value: It return a string of objects.

jQuery code to show the working of serializeArray() method:





    <!-- jQuery code to show the working of this method -->
        $(document).ready(function() {
            $("button").click(function() {
                var x = $("form").serializeArray();
                $.each(x, function(i, field) {
                    $("#d").append(field.name + ":" + field.value + ":::");
        #d1 {
            width: 300px;
            height: 100px;
            padding: 20px;
            border: 2px solid green;
            margin-bottom: 10px;
    <div id="d1">
        <form action="">
            Site name:
            <input type="text" name="SiteName" value="GeeksforGeeks">
            <br> Contributor name:
            <input type="text" name="ContributorName" value="KundanJha">
        <!-- click on this button -->
        <button>Click here!</button>
    <div id="d"></div>


Before clicking on the “Click here!” button-

After clicking on the “Click here!” button-


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.