In Express.js, res.send() sends the HTTP response body and ends the response. It sets Content-Length, picks a default Content-Type from the body type, and can add ETag / freshness support for simple (non-streaming) replies.
Use it for plain pages, small APIs, and error messages. Prefer res.json() when the endpoint is JSON-only. For files, use res.sendFile(). For templates, use res.render().
Syntax
Call res.send in your Express.js app. Start with this line.
GET /orders/abc
→ 400 Invalid order id
GET /orders/42
→ 200 Order #42
How It Works
Validate first. Non-digits fail the regex.
return after send. Stops the success res.send (no double response).
400 for bad input. Client knows the request was wrong.
Valid ids continue. Only then is the order message sent.
Compatibility
Runtime Support
res.send() is an Express.js response method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers only receive the finished HTTP response.
✓ Server · Express 4 & 5
res.send()
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
res.send()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 sends an HTTP response body and ends the response. It sets Content-Length, can set Content-Type from the body type, and supports ETag / freshness checks for simple responses.
String, Buffer, Object, Array, Boolean, or undefined. Strings default to text/html; objects and arrays become JSON; Buffers default to application/octet-stream.
res.json() always serializes to JSON. res.send() is general-purpose: strings are treated as HTML unless you set the type first.
Yes. Chain status first: res.status(404).send('Not found'). Or use res.sendStatus() when you only need a status.
No. It runs on your Express server. The browser only receives the finished HTTP response.