DevTools: Convert network requests to code, or even to a terminal commandLast updated: 23rd March 2023
To try this out
- Go to https://dinoipsum.com/ and click 'Give me dinos'.
- Go to the Network Panel in DevTools, and make sure the panel is recording.
- In the web page, click 'Give me dinos' again, notice how the resource appears in the Network panel.
- Right click on that resource and select Copy as fetch.
Note: Extra HTTP request headers have been removed in the following snippet. Normally, DevTools preserves the original HTTP request headers in the
const response = await fetch( "https://dinoipsum.com/api?paragraphs=2&words=3&format=text" ); const text = await response.text(); document.querySelector("p").innerText = text;
You can also copy as cURL, where you get a terminal command in your clipboard:
To use this, follow the previous steps but select Copy as cURL when you right click on the network resource.
This can be especially helpful when submitting bug reports.
This feature is supported in Firefox, Edge, Chrome and Safari.