In Express.js, express.raw() is built-in middleware that reads the request body into a Buffer on req.body. By default it matches Content-Type: application/octet-stream.
Use it for webhooks, signatures, or any binary/raw payload you must not parse as JSON. Mount it with app.use() before routes that need the buffer.
Syntax
Call express.raw in your Express.js app. Start with this line.
Express
express.raw([options])
Call
What it does
express.raw([options])
Returns middleware that sets req.body to a Buffer.
Install with npm install express. Create the app with const app = express() before mounting parsers.
Parameters
Parameter
Description
options
Optional. Parsing settings. Omit for defaults.
options.limit
Optional. Max body size. Default '100kb'.
options.type
Optional. Which Content-Type to parse. Default 'application/octet-stream'.
Optional. verify(req, res, buf, encoding) — inspect the buffer; throw to abort.
Return Value
express.raw() returns a middleware function. Mount it with app.use(express.raw()). After it runs, req.body is a Buffer (or undefined if the type did not match).
POST /bin (small body)
→ 204
POST /bin (body > 50kb)
→ Error: request entity too large (413)
How It Works
Pass limit.{ limit: '50kb' } caps the body.
Small bodies succeed. Handler runs and returns 204.
Large bodies fail. Parser stops before your route.
Keep limits modest. Default is already 100kb.
Compatibility
Runtime Support
express.raw() is Express.js built-in middleware. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not execute it.
✓ Server · Express 4.17+ & 5
express.raw()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
express.raw()Express on Node.js
Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.
Frequently Asked Questions
It is middleware that reads matching request bodies into a Buffer on req.body. Default Content-Type is application/octet-stream.
Use it for binary payloads or when you need the exact original bytes (for example webhook signature checks).
The Content-Type did not match the type option, the parser was mounted after the route, or there was no body.
Yes. Pass { type: 'application/json' }. Do not also mount express.json() on the same path if you need the raw bytes.
No. It runs on your Node.js server. Browsers only send the HTTP request.