204 No Content
The request succeeded and the server has nothing to put in a body. The response ends after its headers.
What 204 means
A 204 is a complete, successful answer that consists of a status line and headers only. It is not an empty 200: a 204 cannot contain content at all, and a server must not send a Content-Length header with it. The response is finished at the blank line after the headers.
The headers still carry information. They describe the resource as it is after the request was applied, so an ETag on the 204 that answers a PUT is the entity tag of the version you just saved.
Like 200, a 204 is cacheable by default.
Where 204 fits
- DELETE. The resource is gone and there is nothing more to say.
- PUT or PATCH when the client already holds the state it just sent and needs no copy back.
- Saving without leaving the page. A browser that receives a 204 for a navigation or form submission stays on the current page, which is what "save and continue editing" needs.
- CORS preflights. The answer to an
OPTIONSpreflight is all headers, so many servers send it as a 204. - Fire-and-forget endpoints such as analytics beacons, where the client ignores the response anyway.
When 204 is the wrong code
- The server generated values the client needs: an ID, a timestamp, a computed total. Return 200 or 201 with the record.
- A GET for a collection that happens to be empty. That is a 200 with
[], so the client can parse every answer the same way. - The thing was not found. An unknown ID is a 404, not a quiet 204.
- The work has only been queued. That is 202 Accepted.
- Any page you want indexed. A crawler that receives a 204 has no content to process.
Client and server pitfalls
await response.json()throws on a 204, because an empty body is not valid JSON. Checkresponse.status === 204(or the content type) before parsing. Generic API wrappers that always parse JSON are where this bug usually lives.- Do not write a body after a 204 "just in case". The client stops reading at the end of the headers. On a reused connection the stray bytes can be taken for the start of the next response, and browsers may reject the response outright.
- Some frameworks send 204 automatically when a handler returns nothing. If a client then fails on the missing body, the fix is to return something on purpose with 200, or to make the client accept the 204.
- If you switch an endpoint from 200 to 204, treat it as a breaking change for clients that read the body.
204 compared with 200, 202 and 304
| Code | Body | Meaning |
|---|---|---|
| 204 No Content | Never | Done. Nothing to return. |
| 200 OK | Expected | Done. Here is the result. |
| 202 Accepted | Optional | Received. The work happens later. |
| 304 Not Modified | Never | Nothing was done. Your cached copy is still good. |
204 and 304 both arrive without a body, but for opposite reasons: a 204 confirms that an action was carried out, while a 304 tells a cache it can keep using what it has.
Example 204 response
HTTP/1.1 204 No Content
Date: Sat, 14 Nov 2026 10:15:00 GMT
ETag: "9c2b-v5"This is the whole response to a successful PUT: no body and no Content-Length. The ETag identifies the version that was just stored.
Defined in RFC 9110, section 15.3.5.
Questions
Can a 204 response have a body?
No. A 204 ends after the header section and cannot contain content, and it must not include a Content-Length header. If you have something to return, use 200.
Should a successful DELETE return 204 or 200?
Use 204 when the deletion is done and there is nothing to add, and 200 when the response includes a body describing the outcome. If the deletion has only been scheduled, 202 Accepted is the accurate code.
Why does response.json() fail on a 204?
There is no body, and an empty string is not valid JSON, so the parser throws. Check the status code before parsing, or have your API wrapper return null for 204 responses.
What does a browser do when a page request returns 204?
It stays where it is. The current page remains on screen and the address bar does not change, which is why 204 suits save actions that should not navigate away.