Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including form-data-to-object with all npm packages installed. Try it out:

var formDataToObject = require("form-data-to-object")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

form-data-to-object v0.2.0

Converts application/x-www-form-urlencoded keys to plain JS object

form-data-to-object

Converts application/x-www-form-urlencoded data structure to plain JS object

API

  • formData.toObj() - Converts keys in x-www-form-urlencoded format on an object to a normal object
  • formData.fromObj() - Converts a normal object to object with keys in x-www-form-urlencoded format

// keys in x-www-form-urlencoded format
{
  'foo': 'bar',
  'foo2[name]': 'bar2',
  'foo3[0]': 'bar3',
  'foo3[1][name]': 'bar4'
}

// converts from/to

// normal object
{
  foo: 'bar',
  foo2: {
    name: 'bar2'
  },
  foo3: ['bar3', {
    name: 'bar4'
  }]
}
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free