Debugging JSON APIs Efficiently
2026-01-16
The Toolbox
When an API returns a 500 error or unexpected JSON, you need the right tools.
1. cURL + jq
The command line is your friend.
curl -s https://api.example.com/users | jq .
jq formats the output and allows you to query specific fields instantly.
2. Browser DevTools
- Network Tab: Click on a request and switch to the "Response" or "Preview" tab. Modern browsers format JSON automatically.
- Console: You can copy the response object to the global variable (Store as global variable) and manipulate it with JS.
3. Postman / Insomnia
Dedicated API clients are essential for:
- Saving request collections.
- Testing different HTTP methods (POST, PUT, DELETE).
- Setting headers (Authorization, Content-Type).
Common Issues
- Content-Type Mismatch: Sending JSON but forgetting
Content-Type: application/json. - Trailing Commas: Standard JSON does not allow trailing commas (unlike JS).
- Date Formats: JSON has no Date type. ISO 8601 strings (
2026-01-16T12:00:00Z) are the standard, but Unix timestamps are also common.