How to fix malformed json returned by api responses
- Step 1Copy the raw API response body — From browser DevTools Network tab, find the failing request. Copy the raw response body — not the parsed object. The raw body contains the invalid JSON characters.
- Step 2Paste and fix — Paste the raw response body. The fixer identifies the specific syntax violations and corrects them. Review the correction list to understand what the API is producing incorrectly.
- Step 3Use the fixed JSON — Copy the fixed JSON for analysis or use in bug reports. If the API is one you control, use the error list to fix the server-side serializer. If it's a third-party API, report the non-standard output.
- Step 4Add a client-side fix for persistent issues — If the third-party API cannot be fixed, add a client-side pre-processor: const fixed = responseText.replace(/NaN/g, 'null').replace(/Infinity/g, 'null'); const data = JSON.parse(fixed). Document the workaround clearly.
Frequently asked questions
Why does JSON not allow NaN and Infinity?+
JSON represents a finite, well-defined set of values. NaN and Infinity are IEEE 754 floating-point concepts that have no JSON representation — JSON only supports finite numeric values, strings, booleans, null, objects, and arrays. When a JSON serializer emits NaN or Infinity, it is violating the JSON specification. The fix is to replace these values with null or an appropriate numeric sentinel value.
How do I fix an API that wraps responses in a JSONP callback?+
JSONP responses look like: callback({...json...}). Strip the function call wrapper with a regex: const json = responseText.replace(/^\w+\(/, '').replace(/\)$/, ''). Then parse the extracted JSON normally. JSONP is largely obsolete — modern cross-origin requests use CORS.
Is the API response data transmitted to JAD Apps?+
No. Format fixing runs entirely in your browser. API response data from third-party services is never transmitted to JAD Apps servers.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.