jQuery .param() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Ajax

Definition

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
CallWhat it does
objPlain object, name/value array, or jQuery form collection
traditionaltrue = shallow; default false = recursive (1.4+)
Return valueURL-encoded string (key=value&…)

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

Parameters

ParameterDescription
Step 1Build a plain object, a serializeArray()-style array, or select form inputs.
Step 2Call $.param(obj) for recursive encoding (default).
Step 3Pass true as the second argument for traditional shallow encoding.

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 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"
Try It Yourself

How It Works

  1. Object. Each own property becomes one key=value pair.
  2. Encode. Keys and values are URL-encoded.
  3. Join. Pairs are joined with &.

Example 2 — Nested Objects and Arrays

Recursive encoding produces PHP/Rails-style bracket notation.

jQuery
var myObject = {
  a: { one: 1, two: 2, three: 3 },
  b: [1, 2, 3]
};

var encoded = $.param(myObject);
var decoded = decodeURIComponent(encoded);

// decoded → a[one]=1&a[two]=2&a[three]=3&b[]=1&b[]=2&b[]=3
Try It Yourself

How It Works

  1. Walk. Nested keys build bracket paths (a[one]).
  2. Arrays. Since 1.4, arrays serialize as name[]=value.
  3. Encode. Brackets become %5B / %5D in the raw string.

Example 3 — traditional: true Shallow Mode

Emulate pre-1.4 behavior — nested objects do not recurse.

jQuery
var myObject = {
  a: { one: 1, two: 2, three: 3 },
  b: [1, 2, 3]
};

$.param(myObject, true);
// decoded → a=[object Object]&b=1&b=2&b=3

$.param(myObject, false);
// decoded → a[one]=1&a[two]=2&a[three]=3&b[]=1&b[]=2&b[]=3
Try It Yourself

How It Works

  1. Shallow. Nested objects become the string [object Object].
  2. Arrays. Repeated keys without brackets (b=1&b=2).
  3. 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.

Next: .serialize() Method

Turn form fields into a query string in one call.

.serialize() Method 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.

9 people found this page helpful