jQuery.param(obj [, traditional]) creates a serialized, URL-encoded string from an array, plain object, or jQuery form collection (since 1.2; traditional since 1.4). Use it for query strings and Ajax data.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$.param({ width: 1680, height: 1050 });
// "width=1680&height=1050"
$.param({ a: [2, 3, 4] }); // "a[]=2&a[]=3&a[]=4" (1.4+)
$.param({ a: [2, 3, 4] }, true); // "a=2&a=3&a=4" (traditional)
// Used internally by $.ajax() / $.get() / $.post() when data is an object
Call
What it does
obj
Plain object, name/value array, or jQuery form collection
traditional
true = shallow; default false = recursive (1.4+)
Return value
URL-encoded string (key=value&…)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Build a plain object, a serializeArray()-style array, or select form inputs.
Step 2
Call $.param(obj) for recursive encoding (default).
Step 3
Pass true as the second argument for traditional shallow encoding.
Return Value
Return Value
Description
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Basic Key/Value Object
Official demo pattern: serialize a simple object and display it.
jQuery
var params = { width: 1680, height: 1050 };
var str = $.param(params);
$("#results").text(str);
// "width=1680&height=1050"
traditional true → a=[object Object]&b=1&b=2&b=3
traditional false → a[one]=1&…&b[]=1&b[]=2&b[]=3
How It Works
Shallow. Nested objects become the string [object Object].
Arrays. Repeated keys without brackets (b=1&b=2).
Explicit. Pass true/false — do not rely on ajaxSettings (3.0+).
Frequently Asked Questions
jQuery.param() creates a URL-encoded query string from a plain object, an array of name/value pairs (like .serializeArray() returns), or a jQuery collection of form inputs. The string is suitable for a URL query or Ajax data. jQuery uses it internally when you pass an object to the data option of $.ajax(), $.get(), or $.post().
By default (traditional false), $.param() recursively encodes nested objects and arrays with bracket notation — e.g. a[one]=1&b[]=2. With traditional true, serialization is shallow: nested objects become [object Object] and arrays use repeated keys without brackets. Prefer recursive for PHP, Rails, and most modern backends.
.serialize() on a form returns a ready-made query string. .serializeArray() returns [{ name, value }, …]. $.param() is the lower-level encoder — you can pass that array: $.param($("form").serializeArray()). Use param() when your data is already a JavaScript object.
Before 1.4, $.param({ a: [2, 3, 4] }) produced a=2&a=3&a=4. From 1.4 onward the default is a[]=2&a[]=3&a[]=4 so PHP and Rails can rebuild arrays. Pass traditional: true for the old repeated-key behavior.
No. There is no universal param-string spec across languages. Deep nesting (objects inside arrays) can parse differently on different servers. For complex payloads prefer JSON in the request body.
Before jQuery 3.0, $.param() could inherit jQuery.ajaxSettings.traditional. Since 3.0, traditional defaults to false unless you pass true. For cross-version compatibility, pass the second argument explicitly when you need shallow serialization.