Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Unserialize data back into DOM forms


jQuery Unserialize (to) Form
Version 1.0.9

Simple jQuery plugin to unserialize data back into forms.


  var s = $("form").serialize(); // save form settings.
  $("form").unserializeForm(s);  // restore form settings

The serialized form data could be saved in a session, perhaps in HTML5 sessionStorage.
Note that saving the serialized data to a cookie is troublesome as not all browsers
implement the same cookie string lengths, so sessionStorage or a SQL db is recommended.

Alternate Usage:

  var cb = function(key, value, [element]) { return true; // or false }

  var s = $("form").serialize();
  $("form").unserializeForm(s, {
    'callback'        : cb,
    'override-values' : false

  callback (optional):
    The above callback is given the element name and value, allowing you to build
    dynamic forms via callback. If you return false, unserializeForm will
    try to find and set the DOM element, otherwise, (on true) it assumes you've
    handled that attribute and moves onto the next.
    The callback will be passed the key and value and, if found, the DOM object it
    will use should you return false. If the DOM object is not found, the third parameter
    will be the empty array jQuery returns when it cannot find an element.
  override-values (optional, default is false):
    Controls whether elements already set (e.g. an input tag with a non-zero length value)
    will be touched by the unserializer. Does not apply to radio fields or checkboxes.
    If you have a use case for radio fields or checkboxes, please file an issue at . Also note this option
    does not apply to a callback, i.e. a callback would still have the opportunity
    to override a value even if this option is set to false. It is up to you as
    the callback author to enforce the behavior you wish.

Known issues:

  * Input element arrays are not cleared before being unserialized, resulting in
    the unserialized values _and_ whatever was already set to be set.

Special thanks / Contributors:
  Thiago Macedo
  Edward Anderson
  Scott Kirkland
  Joshua Weinstein
  Gary Green
  Simon "simmstein"

Something went wrong with that request. Please try again.