User Agents

Web browsers and everyday web tech, explained

Copy a Request as cURL in Chrome: Step-by-Step

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Copying a network request as a cURL command in Google Chrome lets you reproduce an API call or page request from the command line. This is handy for debugging, sharing a request with a teammate, or testing an endpoint with different parameters. You don't need any special tools—just Chrome's built-in Developer Tools and a terminal.

What You'll Need

  • Google Chrome (any recent version, desktop or laptop)
  • A terminal or command prompt (e.g., Terminal on macOS/Linux, Command Prompt or PowerShell on Windows)
  • For requests that require authentication, you'll need the relevant credentials or session cookies already active in the browser

Step-by-Step

  1. Open Developer Tools. In Chrome, right-click anywhere on the page and select Inspect, or press F12 (Windows/Linux) or Cmd+Option+I (macOS).
  2. Go to the Network tab. Click the Network tab in the Developer Tools panel. If you don't see it, click the » (more tabs) icon and select it from the dropdown.
  3. Reproduce the request. If the request you want to copy hasn't happened yet, perform the action that triggers it (e.g., click a button, submit a form, or navigate to a page). The Network tab will record all network activity. If the request already happened before you opened DevTools, you may need to reload the page to capture it.
  4. Find the request in the list. The Network tab shows a table of requests. Look for the one you want—it might be an XHR/fetch call (often labeled with a name like api/data or script.js), a document, or an image. You can filter by type using the filter bar (e.g., click Fetch/XHR to see only API calls).
  5. Right-click the request. In the request list, right-click on the row for the specific request. A context menu will appear.
  6. Select “Copy as cURL”. From the context menu, hover over Copy and then choose Copy as cURL (or Copy as cURL (cmd) if you're on Windows and want the command for Command Prompt). This copies the full cURL command to your clipboard.
  7. Paste and run the command. Open your terminal, paste the command, and press Enter. The command will execute, sending the same request with the same headers, cookies, and body data that Chrome sent.

Common Mistakes

  • Copying the wrong request. The Network tab lists many requests. Make sure you select the one that matches the action you're testing. For example, if you're trying to copy a form submission, look for the request that appears when you click the submit button, not the initial page load.
  • Missing the request because it happened before DevTools opened. If you open DevTools after the request was sent, it won't appear in the list. Reload the page or trigger the action again while the Network tab is open.
  • Using the wrong “Copy as cURL” option. On Windows, there are two options: Copy as cURL and Copy as cURL (cmd). The first uses bash syntax (works in Git Bash or WSL), the second uses cmd syntax. Choose the one that matches your terminal.
  • Forgetting that the command includes cookies and tokens. The copied cURL includes all cookies and authorization headers from the browser session. If you share it, you might expose sensitive session data. Be careful when posting it publicly.

Tips

  • Use the filter bar. To quickly find a specific request, type part of the URL in the filter box, or use the type filters (All, Fetch/XHR, JS, CSS, Img, etc.).
  • Copy as fetch instead. If you're working in JavaScript, you can also choose Copy as fetch to get a fetch() call instead of cURL.
  • Modify the command. Once you have the cURL command, you can edit it to change parameters, headers, or the URL. For example, change a query parameter to test different inputs.
  • Use the “Preserve log” option. If you navigate to a new page, the Network log clears by default. Check the Preserve log checkbox to keep requests from previous pages.
  • For POST requests, check the payload. The cURL command will include the request body (e.g., --data-raw or --data). You can see the exact payload in the Payload tab of the request details.

Troubleshooting

  • The copied command doesn't work in the terminal. This often happens on Windows when using the wrong cURL variant. Try the other “Copy as cURL” option. Also, ensure you're pasting into a shell that supports the syntax (bash for the default option, cmd for the cmd variant).
  • The request is not in the Network list. Make sure you have the Network tab open and that you've triggered the request after opening it. If the page uses service workers or caching, you might need to disable cache (check the Disable cache checkbox in the Network tab) and reload.
  • The command runs but returns an error (e.g., 401 Unauthorized). This usually means the session cookies or tokens have expired or are not valid outside the browser. You may need to refresh the page to get fresh cookies, or manually add a valid token to the command.
  • The command is extremely long. Some requests include many headers and cookies. That's normal. If you want a cleaner command, you can delete unnecessary headers (like User-Agent or Accept) as long as the server doesn't require them.
  • cURL is not installed. On Windows 10 and 11, cURL is included by default. On older systems, you may need to install it. On macOS, cURL is pre-installed. On Linux, it's usually available; if not, install it via your package manager (e.g., sudo apt install curl).

Frequently Asked Questions

Does the copied cURL include cookies?

Yes, the command includes all cookies that Chrome sent with the request, usually in the -H 'Cookie: ...' header.

Can I copy a request that happened before I opened DevTools?

No, the Network tab only records requests that occur while it's open. You need to reload the page or trigger the action again.

What's the difference between “Copy as cURL” and “Copy as cURL (cmd)”?

The first uses bash syntax (single quotes, backslashes for line continuation), the second uses Windows Command Prompt syntax (double quotes, caret for line continuation). Choose based on your terminal.

Is it safe to share a copied cURL command?

Only if you're sure it doesn't contain sensitive data like session cookies, API keys, or passwords. Always review the command before sharing.

Can I copy a request from a mobile browser?

This guide is for desktop Chrome. On mobile, you can use Chrome's remote debugging or a proxy tool to capture requests, but the built-in DevTools interface is not available on mobile browsers.

Does the copied cURL work for WebSocket requests?

No, cURL doesn't support WebSockets. Chrome's “Copy as cURL” works for HTTP/HTTPS requests only. For WebSockets, you'd need a dedicated tool.