Serialize Form Data Into JSON Object In jQuery - serializeToJSON

Serialize Form Data Into JSON Object In jQuery - serializeToJSON

serializeToJSON is a jQuery plugin that serializes a selected form into a JavaScript object and then converts it into a JSON string using the JSON.stringify() method.

How to use it:

1. Include the latest version of jQuery library and jQuery serializeToJSON plugin's script on the webpage.

<script src="//"></script>
<script src="src/jquery.serializeToJSON.js"></script>

2. Serialize an html form into a JS object.

var obj = $("form").serializeToJSON({
    // options here  

3. Convert the JavaScript object to a JSON string.

var jsonString = JSON.stringify(obj);

4. Output the serialized form data.


5. Default options available.

var obj = $("form").serializeToJSON({
    // serialize the form using the Associative Arrays
    associativeArrays: true,
    // convert "true" and "false" to booleans true / false
    parseBooleans: true,
    parseFloat: {
      // the value can be a string or function
      condition: undefined,
      // auto detect NaN value and changes the value to zero
      nanToZero: true,
      // return the input value without commas
      getInputValue: function($input){
        return $input.val().split(",").join("");

Change log:


  • bugfix


  • bugfix


  • v1.2.0: bugfix


  • Fix: Checkbox support


  • Bugfix

This awesome jQuery plugin is developed by raphaelm22. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 28.11.2017
  • Source