cURL to PHP
Paste a curl command and get equivalent PHP code using curl_init, curl_setopt, and curl_exec.
Use the cURL to PHP
curl Command
PHP (cURL)
Copied to clipboard.
Summary
This tool parses a curl command in the browser and emits equivalent PHP code built on the cURL extension. It reads the URL, method, headers, cookies, basic auth, and a JSON or raw body, then generates a ready-to-run script with curl_init, curl_setopt, and curl_exec calls in the right order. Everything runs client-side, so the command you paste never leaves your browser.
How it works
- Paste a curl command, including one copied from a browser devtools network tab.
- The parser tokenizes the command, honoring quotes and backslash line continuations.
- Flags such as -X, -H, -d, -b, -u, -F, and -G are mapped to their curl_setopt equivalents.
- A JSON body is detected automatically and kept as a raw string assigned to CURLOPT_POSTFIELDS.
- The generated PHP script appears in the output box, ready to copy and run.
Use cases
- Turn a "Copy as cURL" request from browser devtools into a PHP script.
- Reproduce an API call from documentation or a support ticket in PHP.
- Convert a curl example from a README into a starting point for an integration.
- Debug an API call by replaying the exact request curl sent, from PHP.
- Translate a webhook test command into a repeatable PHP script.
- Build a quick script around a request captured from a mobile app proxy.
Frequently Asked Questions
Last updated: 2026-09-09 · Reviewed by Nham Vu