# form-data — card for AI agents

Node.js library for creating multipart/form-data streams for file uploads.

Category: HTTP clients and networking · npm package `form-data` · latest version 4.0.6 (checked 2026-11-01)
Install: `npm install form-data`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 65.5 (#649 of all tools, 23 of 126 in its category)
- Used in 31 public projects set up for AI coding agents (0.5%)
- Downloads last week: 237,867,377 (as of 2026-11-24), +33.7% over 4 weeks
- GitHub stars: 2,360 (as of 2026-11-24)
- Last push: 2026-06-12

## Often used with
Axios 67.7%, dotenv 64.5%, date-fns 45.2%, uuid 41.9%, TypeScript 93.5%, Radix UI 45.2%

## Links
- AgentGid page: https://agentgid.com/tools/form-data/
- Homepage: https://github.com/form-data/form-data#readme
- Repository: https://github.com/form-data/form-data


## form-data: send files from Node.js to other services

form-data is a small free Node.js library that packs text fields and files into the same format a web form uses for uploads. Your server can then send a photo, a PDF or an audio file to another service, for example a storage or AI service. Newer Node.js versions have this built in, so new code often does not need it.

### Where to use it
- Pass an upload on to another service: Your server receives a file and forwards it, together with a few text fields, to a storage, email or AI service that expects a form upload.
- Send big files without loading them whole: A long video or a large archive is read from disk piece by piece while it is sent, so the server's memory stays small.
- Upload a file with axios on the server: Your Node.js code already uses axios; form-data builds the upload body and the matching header for it.
- Uploads with Node's own http module: Older code that talks to services through Node's built-in http module can stream the form straight into the request.
- Send a voice note for transcription: A chat bot receives a voice message and posts the audio file to a speech-to-text service from the server. (idea, not from the official pages)
- Tell the service the upload size: Some services refuse uploads without a size in the header; form-data can work it out before sending.

### How to start
- Install it in your Node.js project (pin 4.0.6 or newer).

```
npm install --save form-data
```

- Build the form with append(), then send it with submit() or hand it to your HTTP library with getHeaders().

```
var form = new FormData();
form.append('my_string', 'Hello World');

form.submit('http://example.com/', function (err, res) {
  // res – response object (http.IncomingMessage)  //
  res.resume();
} );
```


### License
Free to use, also in paid and closed-source products, under the MIT license. Keep the copyright and license notice with copies you ship.

### Good to know
- Node.js 18 and newer have their own FormData and fetch built in. New code on a current Node.js often does not need this library.
- Versions before 4.0.4 (and 3.0.4, 2.5.4) had a critical flaw in how they separated fields. Use 4.0.6.
- In the browser the package simply hands back the browser's own FormData; the file-streaming features only exist in Node.js.
- Lists cannot be sent as they are; turn them into text first.
- The project is maintained; 4.0.6 came out on 12 June 2026 and fixed how field and file names are escaped.

Checked 2026-11-11 against: https://github.com/form-data/form-data/blob/master/README.md, https://github.com/form-data/form-data/blob/master/License, https://github.com/form-data/form-data/blob/master/CHANGELOG.md, https://github.com/form-data/form-data/security/advisories/GHSA-fjxv-7rqg-78g4, https://registry.npmjs.org/form-data/4.0.6, https://registry.npmjs.org/form-data, https://raw.githubusercontent.com/form-data/form-data/v4.0.6/lib/browser.js, https://nodejs.org/api/globals.html, https://nodejs.org/api/buffer.html

### Mistakes to avoid
- Don't: form-data below 4.0.4 (or 3.x below 3.0.4, 2.x below 2.5.4) pinned in package.json or a lockfile → Do: npm install form-data@4.0.6 and check that no other package still pulls an old copy (npm ls form-data) (Old versions picked field separators with Math.random(), which an attacker could predict to add extra fields to a request.)
- Don't: axios.post(url, form) in Node.js without form.getHeaders() → Do: axios.post(url, form, { headers: { ...form.getHeaders() } }) (The receiving server needs the boundary from the Content-Type header to split the fields.)
- Don't: form.getBuffer() after appending fs.createReadStream(...) → Do: Use form.submit() or form.pipe(request) for streams; use getBuffer() only with strings and Buffers (getBuffer works only for values a Buffer can hold.)
- Don't: form.append('my_buffer', new Buffer(10)) copied from the README → Do: Buffer.alloc(10) or Buffer.from(data) (The Buffer constructor is deprecated in Node.js and prints a warning.)
- Don't: form.append('tags', ['a', 'b']) → Do: form.append('tags', JSON.stringify(['a', 'b'])) or one append per value (The library does not accept arrays as values.)

### Questions
- Do I still need form-data on Node.js 18 or newer? Often not. Node.js has its own FormData and fetch; form-data still helps with streaming big files and with older code built on axios or http.
- Which version is safe? 4.0.4 or newer (4.0.6 is current). Older 4.x, 3.x before 3.0.4 and 2.x before 2.5.4 picked field separators with a guessable random number.
- Can I get the whole body as one piece to send? Yes, getBuffer() returns it, but only for text and buffers, not for file streams.
- Can I use it in a paid product? Yes, it is MIT-licensed.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
