Lesson 5
Comparing Logs and API Responses
Find regressions in log fragments, curl output, and response bodies without opening a full IDE diff.
Logs and API responses often arrive as copied text, not as tracked files. Text diff is ideal for these quick before/after checks.
Log fragment comparison
Useful cases:
- Error stack traces before and after a deploy
- Request/response logs around a failing endpoint
- Worker job output from two runs
- Filtered log lines copied from a dashboard
Workflow:
- Copy the last known good log snippet.
- Copy the failing log snippet for the same operation.
- Diff them locally.
- Focus on the first changed line, not the entire noisy block.
Logs often contain timestamps, request IDs, and trace IDs that change every run. Ignore those fields mentally, or trim them before diffing when possible.
API response comparison
Useful cases:
curloutput before and after a backend change- Gateway-transformed response vs upstream response
- Pagination page shape changes
- Error payload changes (
400vs422body differences)
Example:
{"status":"ok","items":[{"id":1,"name":"Ada"}]}
{"status":"ok","items":[{"id":1,"name":"Ada","plan":"pro"}]}
If the payload is valid JSON and you care about field-level structure, JSON diff may be better. If the body is partial, minified, escaped, or mixed with headers, text diff is often faster.
Text diff vs JSON diff for responses
| Input shape | Better tool |
|---|---|
| Raw curl output with headers | Text diff |
| Pretty-printed JSON object | JSON diff |
| Log line with embedded JSON | Text diff first |
Need field path like items[0].plan | JSON diff |
Key takeaway
For logs and copied responses, text diff helps you spot the first meaningful change quickly. Trim noise, compare the smallest useful sample, then escalate to JSON diff only when structure matters.
Try both sides in the Text Diff Checker with a short response sample before comparing full payloads.