PACKAGE · FILE UPLOAD

multer

Middleware for handling `multipart/form-data`.

WEEKLY DOWNLOADS 22.0M
STARS 12.1K
FORKS 1.1K
OPEN ISSUES 167
GZIP SIZE 33.3 kB
UNPACKED SIZE 54.4 kB
DEPENDENCIES 6
LAST UPDATED 7mo ago
DOWNLOAD TRENDS

multer downloads · last 12 months

Download trends for multer1 download series from Oct 2025 to Sep 2026. Use left and right arrow keys to inspect monthly values.022.4M44.7M67.1M89.5MOct 2025JanAprJulSep 2026
multer
ABOUT MULTER

Multer is a Node.js middleware designed to handle `multipart/form-data`, which is the encoding type primarily used when submitting forms that include files, non-ASCII data, and binary data. It simplifies the process of receiving file uploads on the server side, abstracting away the complexities of parsing request bodies and managing temporary files.

Multer's core philosophy is to provide a straightforward and configurable solution for file uploads within the Express.js ecosystem. It targets developers building web applications or APIs that require users to upload files, such as images, documents, or videos. The middleware integrates seamlessly with popular Node.js web frameworks, making it a de facto standard for this task.

The package offers flexible configuration options through its `multer()` constructor. Developers can specify where uploaded files should be stored using strategies like `diskStorage` for local file system persistence or `memoryStorage` to keep files in RAM. Customization extends to defining file naming conventions and filtering files based on their type or size.

Multer is most commonly integrated into Express.js applications. It acts as a piece of middleware that intercepts incoming requests, processes the `multipart/form-data` payload, and attaches file information to the `request` object, typically under `req.file` or `req.files`. This makes uploaded file data readily available for further processing, like saving to a database or cloud storage.

With a significant weekly download count of 15.4 million and 12.1K GitHub stars, Multer is a mature and widely adopted package. Its unpacked size is 54.4 kB, with a gzipped bundle size of 33.3 kB, indicating a relatively small footprint for its functionality.

Developers should be aware that Multer is specifically designed for `multipart/form-data` and does not handle other request body formats like `application/json` or `application/x-www-form-urlencoded`. For those cases, other body-parsing middleware should be used separately. Additionally, managing file storage and security (like preventing malicious file uploads) remains the developer's responsibility.

WHEN TO USE
  • When processing file uploads in an Express.js application.
  • To handle forms that include file inputs alongside other text fields.
  • When needing to store uploaded files on the local disk using `diskStorage`.
  • To temporarily hold uploaded files in memory using `memoryStorage`.
  • To filter incoming files based on MIME type or file extension using `fileFilter`.
  • When specifying file destination directory and filename using custom functions within `diskStorage`.
  • To add file metadata like `size` and `mimetype` to the request object.
WHEN NOT TO USE
  • If your application exclusively handles JSON or URL-encoded form data without file uploads.
  • For tasks that involve only basic form submissions without file attachments, as other middleware might be lighter.
  • If you require advanced image manipulation or processing (e.g., resizing, cropping) directly during upload, as Multer focuses solely on transport and storage.
  • When building a serverless function that needs to stream uploads directly to cloud storage without intermediate disk or memory persistence.
  • If you need to parse `application/json` or `application/x-www-form-urlencoded` request bodies, as Multer does not support these formats.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 3
multer vs uploadthing ★ 5.3K · 177.5K/wk multer vs formidable ★ 7.2K · 24.6M/wk multer vs busboy ★ 3.0K · 31.8M/wk