object-to-formdata is a utility library for JavaScript that efficiently serializes plain JavaScript objects into `FormData` instances, a crucial browser API for sending data via `multipart/form-data` requests. Currently at version 4.5.1, it provides options to control how arrays, nulls, booleans, and object/array notation in keys are handled during serialization. The package is actively maintained with regular updates and bug fixes, indicated by its recent releases. Its primary differentiator is the configurable serialization logic, allowing developers to fine-tune how complex data structures are represented in `FormData` compared to manual construction or simpler serializers.
npm install object-to-formdataVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic serialization of a complex JavaScript object, including files, arrays, and nested objects, into a FormData instance using various configuration options, and appending to existing FormData.
Change your import statement to use named exports: `import { serialize } from 'object-to-formdata';`.Update your import statement from `import { formData } from 'object-to-formdata';` to `import { serialize } from 'object-to-formdata';`.Set the `booleansAsIntegers` option to `true` in the configuration object: `serialize(object, { booleansAsIntegers: true })`.Use the `indices: true` option for indexed array keys, or `noAttributesWithArrayNotation: true` / `noFilesWithArrayNotation: true` to suppress bracket notation for non-file/file attributes respectively.
The named export was renamed. Change `import { formData } from 'object-to-formdata';` to `import { serialize } from 'object-to-formdata';`.The package no longer has a default export. Change `import serialize from 'object-to-formdata';` to `import { serialize } from 'object-to-formdata';`.The library correctly serializes nested objects and arrays into appropriate `FormData` keys. When inspecting `FormData` via `console.log`, you'll see the flattened key-value pairs, which is how HTTP `multipart/form-data` works. Ensure your backend is configured to parse these nested key structures (e.g., using a library like `multer` in Node.js).
No dependency data recorded yet.