NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #1694 most downloaded on npm
Encode FormData content into the multipart/form-data format
Last release 1 years ago
04 Jun 2025
Ships unpredictably
gaps range from 2 weeks to 1.6 years
Nearly every release is documented
notes for 39 of 39 stable releases
1 version withdrawn
withdrawn after publishing
5 years old
40 releases · first in 2021
One column per quarter.
Minor Changes #34 da91d4e Thanks @Justin99b ! - Make boundary fully customizable
da91d4e Thanks @Justin99b! - Make boundary fully customizable0cc9cd4 Thanks @octet-stream ! - Remove changelog from distro
0cc9cd4 Thanks @octet-stream! - Remove changelog from distro247fb3e Thanks @octet-stream ! - Remove removeComments from tsconfig.json
247fb3e Thanks @octet-stream! - Remove removeComments from tsconfig.json7f953c7 Thanks @octet-stream ! - Bring back support for CJS via tsup. This package can be used with both ES and CJS modules
7f953c7 Thanks @octet-stream! - Bring back support for CJS via tsup. This package can be used with both ES and CJS modules
5a4cd63 Thanks @octet-stream! - Drop Node.js 16 support. Minimal required version now is Node.js 18
7f953c7 Thanks @octet-stream! - Make FileLike and FormDataLike types compatible with File and FormData
Fix FormDataLike types compatibility with undici ( #19 );
FormDataLike types compatibility with undici (#19);compilerOptions.module value to node16 to meet TS requirements;All changes: v3.0.0...v3.0.1
Remove deprecated isFileLike() utility, use isFile() instead;
isFileLike() utility, use isFile() instead;FormDataEncoder.getContentLength() method.14.x support. Since 3.x the minimal required version is 16.5.x;chunk utility to split value into chunks, if the value size is greater than 65536 bytes. This applied both to Files and string values, because FormDataEnocder supports AsyncIterable returned by File.stream();package.json in esports field of package.json.All changes: https://github.com/octet-stream/form-data-encoder/compare/v2.1.4...v3.0.0
Fix for browser compatibility: Add a fallback for ReadableStream that does not implement Symbol.asyncIterator method;
ReadableStream that does not implement Symbol.asyncIterator method;FormDataEncoder constructor.All changes: https://github.com/octet-stream/form-data-encoder/compare/v2.1.3...v2.1.4
ReadableStream that does not implement Symbol.asyncIterator method;FormDataEncoder constructor.All changes: v2.1.3...v2.1.4
Replace LowercaseObjectKeys TS utility with two interfaces: RawHeaders and FormDataEncoderHeaders. This should resolve #8;
LowercaseObjectKeys TS utility with two interfaces: RawHeaders and FormDataEncoderHeaders. This should resolve #8;All changes: https://github.com/octet-stream/form-data-encoder/compare/v2.1.2...v2.1.3
LowercaseObjectKeys TS utility with two interfaces: RawHeaders and FormDataEncoderHeaders. This should resolve #8;All changes: v2.1.2...v2.1.3
All changes: https://github.com/octet-stream/form-data-encoder/compare/v2.1.1...v2.1.2
All changes: https://github.com/octet-stream/form-data-encoder/compare/v2.1.1...v2.1.2
Fix typings exports in package.json
package.jsonAll changes: https://github.com/octet-stream/form-data-encoder/compare/v2.1.0...v2.1.1
Fix a bug with NaN returned as Content-Length value when FormDataEncoder discovers entries without known length.
NaN returned as Content-Length value when FormDataEncoder discovers entries without known length.All changes: https://github.com/octet-stream/form-data-encoder/compare/v2.0.1...v2.1.0
Adjust minimal required Node.js version to 14.17
14.17All changes: https://github.com/octet-stream/form-data-encoder/compare/v2.0.0...v2.0.1
Remove deprecated isFormDataLike helper. Use isFormData instead.
Encoder from exports;isFormDataLike helper. Use isFormData instead.FormDataEncoder.headers property can be accessed in case-insensitive manner. TypeScript users still have correct TS typings, but only for original and lowercased keys (for example Content-Type and content-type);FormData instance will be preserved in array inside of FormDataEncoder instance (previously it held a reference to given FormData instance);isFileLike helper. Use isFile instead;FormDataEncoder.getContentLength() method. The content-length is now static value, so this method makes no sense. Use FormDataEncoder.contentLength or FormDataEncoder.headers["content-length"] instead.FormDataEncoderHeaders type.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.7.2...v2.0.0
Revert headers bug fix from `1.8.0`, because it introduced breaking change in FormDataEncoder.getContentLength signature and behaviour (See #15).
1.8.0, because it introduced breaking change in FormDataEncoder.getContentLength signature and behaviour (See #15).All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.8.0...v1.9.0
1.8.0, because it introduced breaking change in FormDataEncoder.getContentLength signature and behaviour (See #15).All changes: v1.8.0...v1.9.0
Make isFileLike utility less strict when testing file-ish objects (See #14);
Important notice: I no longer support 1.x branch! You should switch to 2.x if you can!
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.7.2...v1.8.0
Important notice: I no longer support 1.x branch! You should switch to 2.x if you can!
All changes: v1.7.2...v1.8.0
Replace negative lookbehind with replacer function in normalizeValue utility, because it of the compatibility issues in Safari (See: https://github.co
normalizeValue utility, because it of the compatibility issues in Safari (See: https://github.com/octet-stream/form-data-encoder/issues/5)All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.7.1...v1.7.2
Return back isFormDataLike export and mark it deprecated.
isFormDataLike export and mark it deprecated.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.7.0...v1.7.1
Use only lowercased alphabetical + numeric characters in createBoundary function to improve compatibility with existent Blob implementation as it's on
createBoundary function to improve compatibility with existent Blob implementation as it's one of the supported targets;All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.6.0...v1.7.0
Add options argument for FormDataEncoder constructor;
options argument for FormDataEncoder constructor;Content-Length header. It turned off by default, because it is not spec-compliant extension - the web clients does not include it. Use enableAdditionalHeaders option to enable this header:import {Readable} from "stream"
import {FormDataEncoder} from "form-data-encoder"
import {FormData, File} from "formdata-node"
const form = new FormData()
const file = new File(["My hovercraft is full of eels"], "file.txt", {type: "text/plain"})
form.set("field", "Some field")
form.set("file", file)
// You can pass options as the second or third argument
const encoder = new FormDataEncoder(form, {enableAdditionalHeaders: true})
Readable.from(encoder).pipe(process.stdout)
Outputs:
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="field"
Content-Length: 10
Some field
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="file"; filename="file.txt"
Content-Type: text/plain
Content-Length: 29
My hovercraft if full of eels
--form-data-boundary-ZrZBNwvvIVAsVl6f--
To find more information about additional headers per form-data part, see:
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.5.4...v1.6.0
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.5.3...v1.5.4
FileLike interface.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.5.3...v1.5.4
Improvements for typings and documentation.
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.5.2...v1.5.3
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.5.1...v1.5.2
FileLike type.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.5.1...v1.5.2
Fix documentation to match API changes.
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.5.0...v1.5.1
Introduce FormDataEncoder.contentLength property.
FormDataEncoder.contentLength property.readonly properties actually read-only in runtime.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.4.4...v1.5.0
Internal improvements: Use fixed size for boundary because createBoundary function is private.
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.4.3...v1.4.4
Add normalization for non-File field's value following the spec.
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.4.2...v1.4.3
Use less ambiguous name for form data encoder class and exports: Encoder -> FormDataEncoder;
Encoder -> FormDataEncoder;All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.4.1...v1.4.2
Cast Content-Length header to string.
Content-Length header to string.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.4.0...v1.4.1
Slightly optimize createBoundary using bitwise A << 0 instead of Math.floor();
createBoundary using bitwise A << 0 instead of Math.floor();All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.3.0...v1.4.0
(internals) Simplify createBoundary string random generator.
createBoundary string random generator.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.2.0...v1.3.0
Introduce .values() and Symbol.iterator methods, so the Encoder can be converted to Blob:
.values() and Symbol.iterator methods, so the Encoder can be converted to Blob:import {Encoder} from "form-data-encoder"
import {Blob} from "fetch-blob"
const form = new FormData()
form.set("field", "FormData serialization using Blob + from-data-encoder.")
const encoder = new Encoder(form)
const options = {
method: "post",
body: new Blob(encoder, {type: encoder.contentType})
}
const response = await fetch("https://httpbin.org/post", options)
console.log(await response.json())
All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.1.0...v1.2.0
Get rid of nanoid in favour of crypto.randomBytes and focus on Node.js support only, because browsers can handle encoding themselves.
crypto.randomBytes and focus on Node.js support only, because browsers can handle encoding themselves.All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.0.1...v1.1.0
Add escaping for CR, LF and " symbols in name and filename params;
name and filename params;All changes: https://github.com/octet-stream/form-data-encoder/compare/v1.0.0...v1.0.1
Expose isFileLike and isFormDataLike
isFileLike and isFormDataLikeisFormDataLikeAll changes: https://github.com/octet-stream/form-data-encoder/compare/v0.5.1...v1.0.0
Fix for 3rd example in documentation: node-fetch currently does not support async iterables, so the example is not valid when the encoder targeting fe
node-fetch currently does not support async iterables, so the example is not valid when the encoder targeting fetch-blob@3All changes: https://github.com/octet-stream/form-data-encoder/compare/v0.5.0...v0.5.1
Lowercase default boundary string lead characters so it can be used when targeting the Encoder output to Blob:
import {FormData} from "formdata-polyfill/esm-min.js"
import {blobFrom} from "fetch-blob/from.js"
import {Encoder} from "form-data-encoder"
import Blob from "fetch-blob"
import fetch from "node-fetch"
async function toBlob(form) {
const encoder = new Encoder(form) // No need to use custom boundary with lowercased alphabetical characters anymore
const chunks = []
for await (const chunk of encoder) {
chunks.push(chunk)
}
return new Blob(chunks, {type: encoder.contentType})
}
const fd = new FormData()
fd.set("name", "John Doe")
fd.set("avatar", await blobFrom("path/to/an/avatar.png"), "avatar.png")
const options = {
method: "post",
body: await toBlob(fd)
}
await fetch("https://httpbin.org/post", options)
All changes: https://github.com/octet-stream/form-data-encoder/compare/v0.4.0...v0.5.0
Put TextEncoder usage to the instance-wide scope and move CRLF and DASHES to Encoder constructor
TextEncoder usage to the instance-wide scope and move CRLF and DASHES to Encoder constructorContent-Type header for a File from its name propertyEncoder, the mime-types package was removed from dependenciesAll changes: https://github.com/octet-stream/form-data-encoder/compare/v0.3.0...v0.4.0
Improve Encoder#headers API (make it an actual property)
Encoder#headers API (make it an actual property)All changes: https://github.com/octet-stream/form-data-encoder/compare/v0.2.0...v0.3.0
Replace Buffer with Uint8Array + TextEncoder
Buffer with Uint8Array + TextEncoderEncoder#encode() method now yields Uint8Array instead of BufferAll changes: https://github.com/octet-stream/form-data-encoder/compare/v0.1.0...v0.2.0
See readme.md for documentation
See readme.md for documentation
Your coding agent can read these notes before it upgrades. Set up the MCP server →