node package manager


Convert a form to an object, including multi-dimensional name fields.


Convert HTML forms with all their fields and values to multi-dimensional JavaScript objects

Supports Traditional, RequireJS / AWD and CommonJS / Browserfy style imports.

<!-- Include minified script (~2kb) -->
<script src="build/formToObject.min.js"></script>

Using the DOM node id

var myFormObj = formToObject('myFormId');
    saveSettings: 'Save',
    name: 'Serban',
    race: 'orc',
    settings: {
       input: 'keyboard',
       video: {
          resolution: '1024x768',
          vsync: 'on'

Using the actual DOM Node

var $formNode = document.getElementById('myFormId');
var myFormObj = formToObject($formNode);

Sending form data server-side

  'url': '/app/settings/save/',
  'type': 'post',
  'data': formToObject('saveSettingsForm'),
  'success': function(r){}

IE 8, Firefox 3.5, Chrome, Safari, Opera 10, every mobile browser.