Parse JSON sent by a mobile app or frontend to your Express API so you can read it as a normal JavaScript object
Handle HTML form submissions in an Express app by decoding URL-encoded form data automatically
Add payload size limits to your Express server to reject oversized requests before they reach your app logic
Install via npm. Does not handle file uploads or multipart forms, use multer or busboy for those cases.
When a web server receives data sent by a browser or app, that data arrives as raw bytes. Before a Node.js server can do anything useful with it, the data needs to be decoded into a usable format. body-parser is a small library that sits in the middle of that process and handles the decoding automatically. It is part of the Express.js ecosystem, the most widely used web framework for Node.js. The library supports four formats. JSON parsing reads data structured as key-value pairs, which is the most common format for modern APIs. URL-encoded parsing handles form submissions from HTML pages. Raw parsing keeps the data as-is in binary form. Text parsing reads the body as a plain string. Each parser is available separately, so a project can include only the formats it needs. Once body-parser processes an incoming request, the decoded data is attached to the request object under a property called req.body, where the rest of the application can read it. Each parser can be configured with options: a size limit to reject oversized payloads, encoding settings, whether to accept compressed data, and a custom verification function for extra checks before parsing begins. The README notes an important security consideration: because req.body contains data that came from the user, every property in it should be treated as untrusted and validated before use. A caller cannot assume that a field exists, has the expected type, or is safe to call methods on. The library does not handle file uploads or multipart form data, which have their own complexity. For those use cases, the README points to alternatives such as multer, busboy, and formidable. The full README is longer than what was shown.
← expressjs on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.