jQuery .serializeArray() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Ajax

Definition

.serializeArray() (since jQuery 1.2) encodes successful form controls as an array of { name, value } objects — ready to inspect, filter, or pass to $.param(). It takes no arguments and returns an Array.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("form").serializeArray()
// → [ { name: "a", value: "1" }, { name: "b", value: "2" } ]

// Prefer the <form> itself (not form + children)
// Same successful-control rules as .serialize()
// $.param(arr) === $("form").serialize()
CallWhat it does
Matched setA <form> or form controls to read
name on controlsNameless fields are skipped
ArgumentsMethod takes no parameters
Return valueArray of { name, value }

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Give every field you care about a name attribute.
Step 2Select the <form> (or a set of controls) with jQuery.
Step 3Call .serializeArray() to get [{ name, value }, …].

Return Value

Return ValueDescription
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Basic Array on Submit

Official idea: prevent navigation and log the name/value array.

jQuery
$("#demo").on("submit", function (event) {
  event.preventDefault();
  var fields = $(this).serializeArray();
  $("#json-out").text(JSON.stringify(fields, null, 2));
});
Try It Yourself

How It Works

  1. Intercept. The submit handler runs before navigation.
  2. Stop reload. preventDefault() keeps the user on the page.
  3. Read. .serializeArray() builds the name/value array.

Example 2 — Iterate with $.each

Docs-style demo: rebuild a live results list from field.name and field.value.

jQuery
function showValues() {
  $("#results").empty();
  $.each($("form").serializeArray(), function (i, field) {
    $("#results").append(field.name + "=" + field.value + " ");
  });
}

$("input, select").on("click change", showValues);
showValues();
Try It Yourself

How It Works

  1. Read. Each event calls .serializeArray() again.
  2. Loop. $.each walks every { name, value } entry.
  3. Display. Append each pair to the results area.

Example 3 — $.param(serializeArray()) Equals .serialize()

Prove the official equivalence: both produce the same query string.

jQuery
var $f = $("#demo-form");
var fromArray = $.param($f.serializeArray());
var fromSerialize = $f.serialize();

$("#match").text(fromArray === fromSerialize ? "Match!" : "Mismatch!");
$("#string").text(fromSerialize);
Try It Yourself

How It Works

  1. Array path. Build the array, then encode with $.param().
  2. String path. .serialize() does that pipeline internally.
  3. Same rules. Both use identical successful-control filtering.

Frequently Asked Questions

jQuery .serializeArray() encodes successful form controls as an array of plain objects — each with name and value properties. Call $("form").serializeArray() to get [{ name: "email", value: "[email protected]" }, …]. It takes no arguments and returns an Array, not a string.
.serializeArray() returns an array of { name, value } objects. .serialize() returns the same data as one URL query string. They use the same successful-control rules. Note: $(form).serialize() equals $.param($(form).serializeArray()).
Same rules as native HTML form submit: each control needs a name and must not be disabled. Checkboxes and radios appear only when checked. File inputs and submit button values are excluded. Missing value attributes become an empty string.
Yes — that is what .serialize() does internally. $.param($("form").serializeArray()) produces the same string as $("form").serialize(). You can modify the array first, then call $.param().
Yes — JSON.stringify($("form").serializeArray()) is valid JSON. Many APIs expect a flat object instead; map the array with a loop or reduce. For uploads use FormData, not serializeArray.
Prefer $("form").serializeArray(). Selecting both the form and its children in one set can duplicate entries. You may select individual controls when they are not inside a form.

Next: ajaxStart Event

Show a page-wide loading indicator when the first Ajax request begins.

ajaxStart Event tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful