res.end()

Ends the response process without higher-level body formatting.

Since Express 4 (Node http) Spec ↗

Syntax

res.end([data][, encoding])

Parameters

NameTypeRequiredDescription
data string | Buffer No Optional final chunk to write before ending.
encoding string No Encoding for string data.

Returns

Response — The response object.

Examples

app.get('/ping', (req, res) => {
  res.status(204).end();
});
Output
(204 No Content, empty body)
app.get('/stream', (req, res) => {
  res.write('chunk 1\n');
  res.write('chunk 2\n');
  res.end();
});
Output
chunk 1
chunk 2

Notes

This is the low-level Node method. Prefer `res.send`/`res.json` for normal responses since they set headers for you. Use `end()` to finish an empty or manually-streamed response. Must be called exactly once.

See also