json_response=true
, ZenRows captures not only the final HTML content but also all XHR, Fetch, and AJAX requests made during page rendering. This gives you complete visibility into how modern web applications load and update their content.
The JSON Response parameter requires
js_render=true
to function, as it monitors network activity and JavaScript execution within the browser environment.How JSON Response works
JSON Response intercepts and records most network activity during JavaScript rendering, creating a comprehensive report of the page’s behavior. The browser monitors every HTTP request made by the page, including background API calls, resource loading, and dynamic content updates. This process captures:- All XHR and Fetch requests with full request/response details
- The final rendered HTML content
- Optional JavaScript instruction execution reports
- Optional screenshot data of the rendered page
- Complete request and response headers for network analysis
Basic usage
Enable JSON Response by adding thejson_response=true
parameter to your JavaScript rendering request:
JSON Response structure
The JSON Response contains several key fields that provide different types of information. Here’s a complete example of what a typical JSON response looks like:JSON
Response fields
-
html
- The complete rendered HTML content of the page as a string. This content is JSON-encoded and contains the final DOM state after all JavaScript execution and dynamic loading. -
xhr
- An array containing all XHR, Fetch, and AJAX requests made during page rendering. Each request object includes:url
- The complete URL of the requestbody
- The response body contentstatus_code
- HTTP status code (200, 404, 500, etc.)method
- HTTP method used (GET, POST, PUT, DELETE, etc.)headers
- Response headers from the serverrequest_headers
- Headers sent with the original request
-
js_instructions_report
(Optional - only present when using JavaScript Instructions) - Detailed execution report including:instructions_duration
- Total execution time in millisecondsinstructions_executed
- Number of instructions processedinstructions_succeeded
- Number of successful instructionsinstructions_failed
- Number of failed instructionsinstructions
- Array of individual instruction details with parameters, success status, and timing
-
screenshot
(Optional - only present when using the Screenshot feature) - Screenshot data containing:data
- Base64-encoded image datatype
- Image format (typically “image/png”)width
- Screenshot width in pixelsheight
- Screenshot height in pixels
When to use JSON Response
JSON Response is essential for these scenarios:Dynamic content loading:
- AJAX-loaded content - When page content is loaded dynamically via XHR calls, JSON Response captures these API requests so you can access the raw data directly from the network calls rather than parsing it from the rendered HTML
- API-dependent data - Content that appears after external API calls
- Progressive loading - Pages that load content in stages
- Conditional content - Elements that appear based on user state or preferences
- Real-time applications - Capture live data feeds and WebSocket-like communications
- Search platforms - Monitor search API calls and result loading patterns
Debugging and development:
- Network troubleshooting - Identify failed requests or slow API calls
- Content loading analysis - Understand how content loads in stages
- Performance monitoring - Track request timing and response sizes
- Integration testing - Verify that all expected API calls are made
- Security analysis - Monitor for unexpected network activity
- JavaScript Instructions debugging - When using JavaScript Instructions, JSON Response provides detailed execution reports to help debug instruction failures and timing issues
For comprehensive guidance on debugging JavaScript Instructions using JSON Response, see our JavaScript Instructions Debugging documentation.
Best practices
Combine with appropriate parameters
Use JSON Response with other features such aswait
or wait_for
to guarantee the content will be loaded:
Python
Filter and process network requests
Focus on relevant requests to avoid information overloadPython
Troubleshooting
Common issues and solutions
Issue | Cause | Solution |
---|---|---|
Empty XHR array | No network requests made | Verify the page actually makes AJAX calls |
Missing expected requests | Requests happen after page load | Increase wait time or use wait_for |
Large response size | Many network requests captured | Filter requests to focus on relevant ones |
JSON parsing errors | Malformed response data | Add error handling for JSON parsing |
Incomplete request data | Requests still in progress | Ensure adequate wait time for completion |
Response size exceeds plan limits | Too much data captured | Upgrade plan or use Block Resources parameter |
Handling oversized responses
When JSON responses become too large and exceed your plan’s limits: Response size exceeded error: If your response exceeds the maximum size allowed by your plan, you’ll receive an error indicating the limit has been reached. Solutions:- Upgrade your plan - Higher-tier plans support larger response sizes
- Use Block Resources parameter - Remove unnecessary content like images, stylesheets, and scripts:
- Filter XHR requests - Focus on specific API endpoints rather than capturing all network activity
- Use shorter wait times - Reduce the time window to capture fewer requests
The Block Resources parameter can significantly reduce response sizes by preventing the loading of images, CSS files, JavaScript files, and fonts that aren’t essential for your scraping needs.
Debugging missing network requests
When expected API calls don’t appear in the XHR array:1
Verify if XHR requests are actually made
Python
2
Increase wait time for slow requests
Python
3
Use `wait_for` to ensure content loads
Python
Pricing
Thejson_response
parameter doesn’t increase the request cost. You pay the JavaScript Render (5 times the standard price) regardless of the wait value you choose.
Frequently Asked Questions (FAQ)
Do I need js_render=true to use json_response?
Do I need js_render=true to use json_response?
Yes, the
json_response
parameter requires js_render=true
because it monitors network activity that occurs during JavaScript execution. Without JavaScript rendering, there would be no XHR/Fetch requests to capture.Will json_response capture all network requests made by the page?
Will json_response capture all network requests made by the page?
JSON Response captures XHR, Fetch, and AJAX requests made during the page rendering process. It does not capture initial resource loading (like CSS, images, or the main HTML request), but focuses on dynamic API calls and background requests.
How large can the JSON response become?
How large can the JSON response become?
The size depends on the number of network requests and their response sizes. Pages with many API calls can generate large JSON responses. Consider filtering requests or processing data in chunks for very active pages.
Can I get only the XHR data without the HTML content?
Can I get only the XHR data without the HTML content?
No, the JSON Response always includes both HTML and XHR data. However, you can ignore the HTML field in your processing and focus only on the XHR array if that’s all you need.
What happens if a network request fails during page loading?
What happens if a network request fails during page loading?
Failed requests are still captured in the XHR array with their actual status codes (e.g., 404, 500). This allows you to analyze both successful and failed network activity.
Does json_response work with Premium Proxy?
Does json_response work with Premium Proxy?
Can I use json_response to monitor WebSocket connections?
Can I use json_response to monitor WebSocket connections?
No, JSON Response only captures HTTP-based requests (XHR, Fetch, AJAX). WebSocket connections use a different protocol and are not captured in the XHR array.
How do I handle pages that make requests after user interactions?
How do I handle pages that make requests after user interactions?
Use JavaScript Instructions to simulate user interactions (such as clicks and scrolls) before capturing the page. This will trigger additional network requests that will be included in the JSON response.