API Error: Malformed JSON in request body (entity.parse.failed / JSON parse error)
The server couldn’t parse the request body as JSON, so it rejected the request before looking at any field.
Meaning
This is the server-side twin of the browser’s “Unexpected token in JSON” error: the bytes your client sent are not valid JSON. Express/body-parser reports it as type entity.parse.failed, Spring as “JSON parse error”, Django REST Framework as “JSON parse error - Expecting value”, and many APIs simply say “Malformed JSON” or “Problems parsing JSON”.
Typical culprits are hand-built JSON strings, single quotes, trailing commas, an object passed without JSON.stringify (sent as “[object Object]”), or a body sent as form data while the header says application/json.
Common causes
- Body built by string concatenation (unescaped quotes, newlines)
- Single quotes or trailing commas (valid in JS, invalid in JSON)
- Object sent without JSON.stringify → "[object Object]"
- Content-Type: application/json but the body is form-encoded or empty
- Shell quoting in curl mangled the JSON
⚡ Quick fix
- Always build bodies with JSON.stringify / json.dumps, never by hand
- Validate the payload with a JSON linter
- Make the body and Content-Type match
Detailed fix by platform
Node.js
await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
curl
- bash
# put the JSON in a file to avoid shell quoting problems curl -X POST https://api.example.com/v1/items -H 'Content-Type: application/json' --data @body.json
Express
- bash
app.use(express.json()); app.use((err, req, res, next) => { if (err.type === 'entity.parse.failed') return res.status(400).json({ error: 'Malformed JSON' }); next(err); });
How to diagnose
- Raw body — Paste the exact bytes sent into a JSON validator
- Header — Content-Type matches the body format?
- Client — Was the object stringified?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Report a correction or suggest an improvement
Last updated 7 Oct 2026