formidable
Formidable is a Node.js module for parsing form data, especially file uploads. Unlike Multer which is Express middleware, Formidable is framework-agnostic and w…
Installation
npm install formidable
yarn add formidable
pnpm add formidable
Import
import formidable from 'formidable';
Quick Example
import http from 'http';
import formidable from 'formidable';
const server = http.createServer(async (req, res) => {
if (req.url === '/upload' && req.method === 'POST') {
const form = formidable({ maxFileSize: 10 * 1024 * 1024 });
const [fields, files] = await form.parse(req);
res.end(JSON.stringify({ fields, files }));
}
});
server.listen(3000);About formidable
Formidable is a Node.js module for parsing form data, especially file uploads. Unlike Multer which is Express middleware, Formidable is framework-agnostic and works with any Node.js HTTP server including Express, Koa, Fastify, and the raw http module. The library streams uploaded files directly to disk rather than buffering them in memory, making it suitable for handling large file uploads without excessive memory consumption. Formidable supports multipart/form-data (file uploads), application/x-www-form-urlencoded (form submissions), and application/json (JSON bodies). The library provides event-based (form.on('file', ...)) and promise-based (form.parse(req)) APIs with progress tracking for upload monitoring. Configuration options include uploadDir for file destination, maxFileSize for upload limits, multiples for allowing multiple files per field, and keepExtensions for preserving original file extensions. Formidable handles file renaming, temporary file management, and proper cleanup of partially uploaded files. The library is often preferred over Multer in non-Express projects or when framework-agnostic file upload handling is needed. Formidable has been actively maintained since 2010 and is one of the most battle-tested file upload libraries in the Node.js ecosystem.
Quick Facts
| Package | formidable |
| Category | File System |
| Weekly Downloads | 8M+ |
| License | MIT |
| Install | npm install formidable |
Related Packages
Multer is a Node.js middleware for handling multipart/form-data, which is primarily used for uploadi…
Express is the most widely used web application framework for Node.js, providing a minimal and flexi…
Sharp is the highest-performance Node.js image processing library, using the libvips image processin…
fs-extra is a drop-in replacement for Node.js's built-in fs module that adds additional file system …
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.