form-data

Build readable multipart/form-data streams in Node.js for forms and file uploads

Library
npm
v4.0.6
2,354stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
65/100Good
Development Activity52
Maintenance36
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture78
Code Quality80
Innovation85
Learning Curve82

form-data is a Node.js library for constructing readable multipart/form-data streams, the encoding browsers use to submit forms and file uploads. Its API is modeled on the XMLHttpRequest-2 FormData interface, so you append string, buffer, and stream values to a form and pipe or submit the result to any web application.

As one of the most-downloaded packages in the npm ecosystem, it is the standard building block behind file-upload support in HTTP clients like axios, node-fetch, and request. It handles boundary generation, content-type detection, content-length calculation, and header assembly so you can post files and mixed fields without hand-writing the multipart wire format.

What You Get

  • A FormData class that streams multipart bodies without buffering entire files in memory
  • Automatic boundary generation, content-type detection via mime-types, and content-length calculation
  • A built-in submit() helper plus getHeaders()/getBuffer() for integration with axios, node-fetch, and request
  • Hand-written TypeScript definitions (index.d.ts) for typed usage
  • Per-part options for filename, filepath, content type, custom headers, and known length

Common Use Cases

  • Uploading files from a Node.js backend to a third-party API or storage service
  • Posting mixed form fields (strings, buffers, file streams) to an HTTP endpoint
  • Providing the multipart body that HTTP clients such as axios and node-fetch send
  • Streaming large files as upload parts without loading them fully into memory

Under The Hood

Architecture

The core is a single FormData class in lib/form_data.js (~500 lines) that inherits from combined-stream’s CombinedStream, making the form itself a readable stream. append() wraps each value with a generated multipart header and trailing line break and pushes it onto the combined stream, deferring stream reads until the consumer pulls data. Length bookkeeping is split between _overheadLength, _valueLength, and a _valuesToMeasure queue that getLength() resolves in parallel via asynckit, while submit() builds an http/https request from a URL or options object and pipes the form into it.

Tech Stack

Pure JavaScript (100% of the repo) targeting Node >= 6, with hand-written TypeScript definitions in index.d.ts. Runtime dependencies are minimal and focused: combined-stream for stream concatenation, asynckit for parallel length measurement, mime-types for content-type detection, plus hasown and es-set-tostringtag for safe property and tag handling. Tooling uses ESLint (ljharb config), istanbul for coverage, tape for tests, and browserify to produce the browser build declared via the browser field.

Code Quality

The library is mature and well-tested: 29 integration test files under test/integration plus static tests cover boundaries, custom headers, length calculation, submission variants, and streaming. The code carries JSDoc annotations and is security-conscious — escapeHeaderParam() escapes CR, LF, and quotes to block multipart header injection, backed by dedicated test-header-injection.js and test-boundary-prediction.js tests. Error handling surfaces length-calculation failures through callbacks rather than swallowing them.

API Design

The public API is deliberately small and familiar, mirroring the browser XMLHttpRequest-2 FormData interface: append(), getHeaders(), getBoundary(), getBuffer(), getLength(), and submit(). Getting started takes only a few lines, per-part options (filename, contentType, knownLength, custom headers) cover advanced cases, and the README documents integration recipes for axios, node-fetch, and request. Consistent naming and thorough docs keep the learning curve low.

Used by 45 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
49%
MPL 2.0

Artillery

Devops · Developer Tools

9,054

Cloud-scale load testing and functional testing for APIs, WebSockets, gRPC, and headless browsers, distributed across AWS Lambda or Fargate with zero infrastructure to manage.

View details
89
Repo Health
73
Technical
68
Dependency
Built with
TypeScript49%
JavaScript48%
Updated 5 days ago
Python
68%
Other

Baserow

No Code Platforms · Databases

5,635

Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Python68%
JavaScript15%
Vue12%
Updated today
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,872

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
95
Repo Health
82
Technical
66
Dependency
Built with
TypeScript100%
Updated yesterday
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
JavaScript
82%
Other

Countly

Analytics · Marketing

5,887

Privacy-first, self-hosted analytics and customer engagement platform with full data ownership, GDPR compliance, and AI-powered insights across mobile, web, desktop, and IoT.

View details
96
Repo Health
82
Technical
68
Dependency
Built with
JavaScript82%
Updated today
TypeScript
80%
Other

Directus

CMS · Low Code Platforms

37,462

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
93
Repo Health
82
Technical
78
Dependency
Built with
TypeScript80%
Vue18%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search