jQuery param() Method

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Ajax Utilities

What You’ll Learn

$.param() turns JavaScript data into URL-encoded query strings. This tutorial covers the official signatures, plain object and array serialization, the serializeArray() input format, recursive bracket notation for nested data, the traditional shallow mode, how jQuery uses param internally for Ajax data, function return values since 1.3, jQuery 3.0 default changes, and when to prefer JSON over param strings.

01

Query Strings

$.param(obj)

02

Nested Objects

a[b]=1 style

03

Arrays

a[]=1&a[]=2

04

traditional

Shallow encoding

05

Forms

serializeArray()

06

Ajax data

Used by $.ajax()

Introduction

Every GET request with a query string and every POST with application/x-www-form-urlencoded body needs data encoded as key=value&key2=value2. You could concatenate strings by hand — but special characters, nested objects, and arrays get messy fast. jQuery.param() handles the encoding rules for you.

Pass a plain object like { width: 1680, height: 1050 } and get back width=1680&height=1050. Pass nested structures and jQuery walks them recursively, producing bracket notation that PHP and Ruby on Rails understand. The same function powers $.serialize() under the hood and runs automatically when you pass an object to the data option of $.ajax(), $.get(), or $.post().

Understanding jQuery.param()

jQuery.param() accepts an array, a plain object, or a jQuery object containing form input elements with name attributes. It returns a single URL-encoded string — never a parsed object. That string is ready to append after ? in a URL or to send as the body of a form-encoded POST.

Since jQuery 1.4, the default encoder is recursive: nested objects become keys like a[one], arrays become b[]. Pass true as the second argument for traditional shallow serialization that matches jQuery 1.3 behavior. Since jQuery 3.0, always pass traditional explicitly when you need it — do not rely on jQuery.ajaxSettings.traditional.

💡
Beginner Tip

Use decodeURIComponent($.param(obj)) when debugging — it shows human-readable brackets instead of %5B escapes. For complex nested payloads destined for a JSON API, skip param strings entirely and send JSON.stringify(data) with contentType: "application/json".

📝 Syntax

The official jQuery API accepts two signatures:

Basic form — jQuery.param( obj ) (since 1.2)

jQuery
jQuery.param( obj )

Serialize obj with recursive encoding (traditional: false).

With traditional flag — jQuery.param( obj, traditional ) (since 1.4)

jQuery
jQuery.param( obj, traditional )

When traditional is true, use shallow serialization — nested objects stringify as [object Object] and arrays use repeated keys without brackets.

Accepted obj types

  • Plain object{ width: 1680, height: 1050 }width=1680&height=1050
  • Array of name/value pairs — the format returned by $.serializeArray(): [{ name: "first", value: "Rick" }, ...]
  • jQuery collection — form inputs with name attributes; jQuery reads their current values

Function values (since 1.3)

If a property value is a function, jQuery calls it and serializes the return value, not the function itself.

Return value

  • Returns a String — URL-encoded query representation. Empty input yields an empty string.
  • Does not include a leading ? — append manually when building URLs.

⚡ Quick Reference

GoalCode
Serialize a plain object$.param({ width: 1680, height: 1050 })
Nested object (recursive)$.param({ a: { one: 1, two: 2 } })a[one]=1&a[two]=2
Array (recursive)$.param({ tags: ["js", "jquery"] })tags[]=js&tags[]=jquery
Shallow / legacy encoding$.param(obj, true)
From serializeArray() output$.param($("form").serializeArray())
Append to URLurl + "?" + $.param({ q: "jquery" })
Debug human-readabledecodeURIComponent($.param(obj))
Pass to $.get() data$.get("/search", { q: "ajax", page: 1 }, fn) — jQuery calls $.param internally
Complex payloadsPrefer JSON.stringify(data) with contentType: "application/json"

📋 $.param() vs $.serialize() vs URLSearchParams vs JSON body

Four ways to turn data into something an HTTP request can send — pick based on input shape and server expectations.

$.param()
objects & arrays

$.param({ a: { b: 1 } }) — recursive bracket notation; accepts plain objects and serializeArray() arrays

$.serialize()
form → string

$("form").serialize() — reads live form field values; uses $.param() internally on the collected pairs

URLSearchParams
native flat

new URLSearchParams({ q: "jquery" }) — browser built-in; flat key/value only, no nested object recursion

JSON body
application/json

JSON.stringify(data) with contentType: "application/json" — best for complex nested API payloads

Use $.param() when you have a JavaScript object or name/value array and need a query string for GET URLs or form-encoded POST bodies. Use $.serialize() when the data lives in a DOM form. Use URLSearchParams for simple flat params without jQuery. Use JSON when the server expects a structured body, not bracket notation.

Examples Gallery

Five progressive examples from a basic key/value object through nested recursive encoding, traditional shallow mode, form serialization, and building a GET URL for Ajax. Each links to a Try-it lab where you can edit and run the code in the browser.

📚 Core Patterns

Serialize plain objects and compare recursive vs traditional output.

Example 1 — Basic key/value object (official demo pattern)

Adapted from the jQuery API docs: serialize a simple object and display the query string.

jQuery
var params = { width: 1680, height: 1050 };
var str = $.param( params );

$( "#results" ).text( str );
// "width=1680&height=1050"

// Human-readable for debugging
console.log( decodeURIComponent( str ) );
Try It Yourself

How It Works

Each own property becomes one key=value pair. Values are URL-encoded — spaces become + or %20, ampersands in values are escaped. This is the simplest case with no nesting.

Example 2 — Nested objects and arrays (recursive encoding)

From the official docs: recursive serialization 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 );

$( "#encoded" ).text( encoded );
$( "#decoded" ).text( decoded );

// encoded: a%5Bone%5D=1&a%5Btwo%5D=2&a%5Bthree%5D=3&b%5B%5D=1&b%5B%5D=2&b%5B%5D=3
// decoded: a[one]=1&a[two]=2&a[three]=3&b[]=1&b[]=2&b[]=3
Try It Yourself

How It Works

Since jQuery 1.4, arrays serialize as name[]=value (not repeated name=value). Nested objects walk each key, building bracket paths. Exercise caution with objects nested inside arrays — server parsers differ.

Example 3 — traditional: true shallow serialization

Emulate pre-1.4 behavior — nested objects stringify and arrays use repeated keys without brackets.

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

var shallow = $.param( myObject, true );
var deep    = $.param( myObject, false );

$( "#shallow" ).text( decodeURIComponent( shallow ) );
$( "#deep" ).text( decodeURIComponent( deep ) );

// shallow decoded: a=[object Object]&b=1&b=2&b=3
// deep decoded:     a[one]=1&a[two]=2&a[three]=3&b[]=1&b[]=2&b[]=3
Try It Yourself

How It Works

Traditional mode does not recurse into nested objects — they become the string [object Object]. Arrays emit repeated keys. Since jQuery 3.0, always pass the second argument explicitly; do not depend on $.ajaxSettings.traditional.

📈 Forms & Ajax Integration

Connect param to form serialization and GET request building.

Example 4 — Serialize a serializeArray() name/value array

Build a query string from the array format jQuery uses internally for forms.

jQuery
// Same structure $.serializeArray() returns
var formData = [
  { name: "first",  value: "Rick" },
  { name: "last",   value: "Astley" },
  { name: "job",    value: "Rock Star" }
];

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

// Equivalent to reading a live form:
// var query = $.param( $( "#my-form" ).serializeArray() );
Try It Yourself

How It Works

When obj is an array, each element must have name and value properties. This is exactly what $.serializeArray() produces — and what $.serialize() passes to $.param() internally.

Example 5 — Build a GET URL and pass data to $.get()

Combine $.param() with manual URL building, and see how $.get() serializes the data object automatically.

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

// Manual URL building
var baseUrl = "/api/search";
var fullUrl = baseUrl + "?" + $.param( filters );
$( "#manual-url" ).text( fullUrl );

// $.get() calls $.param() on data internally — same encoding
$.get( "/api/search", filters, function( data ) {
  console.log( "Response:", data );
} );

// Inspect what jQuery would send (beforeSend peek)
$.ajax( {
  url: "/api/search",
  data: filters,
  beforeSend: function( xhr, settings ) {
    console.log( "Serialized data:", settings.data );
  }
} );
Try It Yourself

How It Works

You rarely call $.param() directly when using jQuery Ajax shorthands — jQuery invokes it for you on the data object. Explicit $.param() is valuable when constructing shareable URLs, logging outgoing query strings, or sending data outside jQuery’s Ajax layer.

🚀 Common Use Cases

  • Search/filter URLs — serialize filter objects and append to the address bar for bookmarkable state.
  • GET Ajax requests — pass plain objects to $.get() knowing jQuery encodes them via $.param().
  • Form-encoded POST bodies — build application/x-www-form-urlencoded payloads from JavaScript objects.
  • Custom form handling — collect field values manually, then $.param(array) instead of native submit.
  • Debugging Ajax — log decodeURIComponent($.param(data)) before sending to verify encoding.
  • Legacy backend compatibility — pass traditional: true when integrating with servers expecting pre-1.4 jQuery output.

🧠 How $.param() Encodes Data

1

Normalize input

Plain objects iterate own keys. Arrays expect { name, value } pairs. jQuery collections read form input names and current values.

obj
2

Resolve function values

Since jQuery 1.3, function properties are invoked and their return values are serialized — not the function source.

functions
3

Walk nested structure

With traditional: false, recurse into objects and arrays, building bracket key paths like a[b] and tags[].

recursive
4

URL-encode each pair

Keys and values pass through encodeURIComponent rules — special characters become percent escapes; spaces become +.

encode
5

Join with &

All pairs concatenate into one string: key1=val1&key2=val2. No leading ? — caller adds that when building URLs.

string
6

Consumed by Ajax or URLs

jQuery attaches the string as query data on GET requests or as the POST body for form-encoded submissions. For JSON APIs, bypass param and send JSON.stringify() instead.

📝 Notes

  • $.param() returns a string, not an object — use it for URLs and form bodies, not for storing structured data.
  • Since jQuery 1.4, default encoding is recursive — arrays use [] brackets, not repeated bare keys.
  • Pass true as the second argument for traditional shallow mode — required for pre-1.4 compatibility.
  • Since jQuery 3.0, traditional defaults to false — do not rely on jQuery.ajaxSettings.traditional.
  • No universal param spec exists — deeply nested structures may parse differently across server languages. Prefer JSON for complex payloads.
  • Function property values are called and their return values serialized (since 1.3).
  • HTML5 input elements in jQuery collections are serialized since jQuery 1.4.
  • $.serialize() and $.serializeArray() use $.param() internally — learn param to understand form serialization.

Browser Support

jQuery.param() is part of jQuery’s core — not a native DOM API. It works wherever jQuery runs: all browsers supported by your jQuery version, including legacy IE with supported jQuery builds.

jQuery 1.2+

jQuery.param() method

Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery builds. Recursive nested serialization arrived in 1.4. Function return value serialization since 1.3. Traditional flag since 1.4. jQuery 3.0 stopped using ajaxSettings.traditional as the implicit default.

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 in any jQuery project. Use $.param() for query strings and form-encoded data; URLSearchParams for flat native params without jQuery; JSON.stringify for complex API bodies.

Conclusion

jQuery.param() is the encoder behind jQuery’s Ajax query strings and form serialization. Learn both signatures (obj and obj, traditional), understand recursive bracket notation for nested data, and reach for JSON when param strings cannot represent your payload reliably across backends.

When you need to read live form fields into that same encoding, continue with the jQuery .serialize() tutorial. Every $.get() and $.post() call with an object data argument uses param internally — explore ajaxStart after serialize for page-wide loading indicators.

💡 Best Practices

✅ Do

  • Pass traditional: true explicitly when you need shallow encoding — never rely on ajaxSettings
  • Use decodeURIComponent($.param(obj)) when debugging encoding output
  • Prefer $.serialize() for live DOM forms; use $.param() for plain JS objects
  • Send JSON with contentType: "application/json" for complex nested API payloads
  • Test param output against your server’s parser — bracket notation varies by framework

❌ Don’t

  • Hand-build query strings with string concatenation — special characters will break
  • Assume all backends parse a[b][c] nested brackets identically
  • Use param strings for deeply nested objects inside arrays — JSON is safer
  • Forget URL-encoding is one-way — decode only for display, not before re-sending
  • Depend on jQuery.ajaxSettings.traditional since jQuery 3.0 — pass the flag directly

Key Takeaways

Knowledge Unlocked

Six things to remember about $.param()

Object in, query string out.

6
Core concepts
[] 02

Recursive Default

a[b]=1 brackets

Since 1.4
T 03

traditional Flag

Shallow legacy mode

2nd arg
fn 04

Function Values

Return value used

Since 1.3
fm 05

Form Bridge

serializeArray()

Forms
aj 06

Ajax Internal

$.get() data option

Integration

❓ 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. It returns a string suitable for appending to a URL or sending as Ajax request 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 using bracket notation — for example a[one]=1&b[]=2. With traditional: true, serialization is shallow: nested objects become [object Object] and repeated keys replace bracket arrays — a=[object+Object]&b=1&b=2. Use recursive encoding for PHP, Ruby on Rails, and most modern backends; use traditional only when you need jQuery 1.3-era compatibility.
$.serialize() on a form returns a ready-made query string. $.serializeArray() returns an array of { name, value } objects. $.param() is the lower-level encoder — you can pass that array directly: $.param($('form').serializeArray()). All three produce URL-encoded strings; param() is the building block when your data is already a JavaScript object rather than DOM form fields.
Before jQuery 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 Ruby on Rails can reconstruct arrays server-side. That is why the second traditional argument exists — pass true to get the old repeated-key behavior.
No universal spec exists for param strings across every language and framework. Deep nesting with objects inside arrays can parse differently on different servers. For complex payloads prefer JSON in the request body (contentType: application/json) rather than pushing deeply nested structures through $.param().
Prior to jQuery 3.0, $.param() could inherit jQuery.ajaxSettings.traditional as its default. Since jQuery 3.0, traditional always defaults to false unless you pass true explicitly. For cross-version compatibility, always pass the second argument when you need shallow serialization — do not rely on ajaxSettings.traditional.
Did you know?

$.param() has existed since jQuery 1.2 — before most Ajax shorthands. The recursive nested encoding that produces a[b]=1 bracket notation arrived in jQuery 1.4 specifically to match PHP and Ruby on Rails server parsers. Before 1.4, $.param({ a: [2, 3, 4] }) produced a=2&a=3&a=4 instead of a[]=2&a[]=3&a[]=4. Since jQuery 3.0, the method no longer reads jQuery.ajaxSettings.traditional as its default — always pass the second argument when you need shallow mode.

Next: jQuery .serialize() Method

Encode successful form controls as a URL query string ready for $.post() and Ajax submits.

jQuery .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.

6 people found this page helpful