jQuery .param() Method

Beginner
8 min read
Updated: Oct 2026
5 examples
Live preview

What Is $.param()?

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.

Remember
$.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
NeedUse
Object → query string$.param(obj)
Form → query string$("form").serialize()
Form → name/value array$("form").serializeArray()
Shallow / legacy encoding$.param(obj, true)
Complex nested dataPrefer JSON body over param strings

How to Use $.param()

Pass data in, get a query string out — then append it to a URL or let Ajax helpers encode for you.

  1. Build a plain object, a serializeArray()-style array, or select form inputs.
  2. Call $.param(obj) for recursive encoding (default).
  3. Pass true as the second argument for traditional shallow encoding.
  4. Append the result after ?, or pass the object to $.get() / $.post() directly.
  5. Use decodeURIComponent() when you need a readable debug view.
PieceRequired?Role
objYesPlain object, name/value array, or jQuery form collection
traditionalOptionaltrue = shallow; default false = recursive (1.4+)
Return value—URL-encoded string (key=value&…)

Pseudocode

Pseudocode
call $.param(obj [, traditional])

if obj is a jQuery collection:
    treat as form inputs (name/value)

if obj is [{ name, value }, …]:
    encode each pair as name=value

if obj is a plain object:
    if traditional is true:
        shallow encode (nested objects → "[object Object]")
        arrays → repeated keys without []
    else:
        recursively walk nested keys
        arrays → name[]=value
        objects → name[key]=value

return joined "key=value" pairs with "&"
(URL-encode keys and values)

Cheat Sheet

Keep these facts handy while building query strings.

TopicDetail
Signature$.param(obj [, traditional])
ReturnsString (URL-encoded query)
Since1.2 · traditional 1.4 · 3.0 default always false
Arrays (default)a[]=2&a[]=3
Arrays (traditional)a=2&a=3
Functions as valuesSince 1.3 — return value is used, not the function string
Form helper$.param($("form").serializeArray())
DebugdecodeURIComponent($.param(obj))

Live Preview

Serialize sample data and compare recursive vs traditional output.

Runs entirely in the browser — no network required.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

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 &.
  4. Use. Append after ? or pass the object to Ajax helpers.

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.
  4. Decode. Use decodeURIComponent() for a readable view.

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+).
  4. When. Use traditional only for legacy backends that expect it.

Example 4 — serializeArray() Format

Encode a name/value array — the same shape forms produce.

jQuery
var formData = [
  { name: "first", value: "Rick" },
  { name: "last", value: "Astley" },
  { name: "job", value: "Rock Star" }
];

$.param(formData);
// "first=Rick&last=Astley&job=Rock+Star"

// Live form:
$.param($("#demo-form").serializeArray());
Try It Yourself

How It Works

  1. Shape. Each array item needs name and value.
  2. Encode. Spaces become + in form-urlencoded style.
  3. Forms. .serializeArray() produces this exact structure.
  4. Bridge. .serialize() uses $.param() under the hood.

Example 5 — Build a GET URL

Append $.param() to a path — same encoding $.get() uses for data.

jQuery
var filters = { q: "jquery param", page: 2, tags: ["ajax", "tutorial"] };

var fullUrl = "/api/search?" + $.param(filters);
// /api/search?q=jquery+param&page=2&tags[]=ajax&tags[]=tutorial

// Same encoding when you pass the object:
$.get("/api/search", filters);
Try It Yourself

How It Works

  1. Encode. $.param(filters) builds the query part.
  2. Join. Prefix with path? for a full URL.
  3. Ajax. Passing data to $.get() uses the same encoder.
  4. Arrays. Tags become tags[]=… with the default mode.

Edge Cases & Pitfalls

Check these before shipping query-string payloads.

nested

Objects inside arrays are fragile

Server frameworks parse deep nesting differently. Prefer flat data or JSON for complex shapes.

traditional

Pass traditional explicitly (3.0+)

Do not rely on jQuery.ajaxSettings.traditional — defaults always start at false now.

shallow

Traditional turns objects into [object Object]

Nested objects are not recursively expanded when traditional is true.

json

No universal param-string spec

For complex structures, send JSON (contentType: "application/json") instead of deep param encoding.

Browser Support

$.param() has been part of jQuery since 1.2 (traditional since 1.4). It works wherever your loaded jQuery version runs. Prefer a current jQuery 3.x build for modern projects.

✓ Stable · jQuery 1.2+

jQuery.param()

Works in every browser that runs your loaded jQuery version. Encoding is done in JavaScript — no special browser API required.

100% With jQuery
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
$.param() Universal

Bottom line: Safe for everyday query strings. Prefer recursive encoding for modern backends, and pass traditional explicitly when you need shallow mode.

Performance Notes

ApproachCostBest for
Flat object $.param()CheapFilters, pagination, simple forms
Deep recursive nestingHigherOnly when the server expects brackets
JSON request bodyClearerComplex nested payloads

Encoding small objects is inexpensive. Cost grows with deep trees and large arrays — keep payloads flat when you can.

Key Takeaways

  • Role: turn objects/arrays into URL-encoded query strings.
  • Default: recursive brackets (a[]=1, a[b]=2) since 1.4.
  • Forms: $.param($("form").serializeArray()) bridges DOM → query.
  • Complex data: prefer JSON over deep param nesting.

One line: $.param() is jQuery’s object-to-query-string encoder for Ajax and URLs.

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()

Turn form fields into a query string in one call.

.serialize() tutorial →

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