cURL to PHP Converter
Convert a curl command to PHP cURL or Guzzle code that sends the same request. Files, uploads, gzip and quoting are handled. Flags it cannot convert are listed.
Loading tool…
How it works
Copy the request as cURL
In Chrome, Edge or Firefox DevTools, right-click a request in the Network panel and choose Copy as cURL. Bash and Windows cmd copies work; use Bash for non-ASCII text.
Pick PHP cURL or Guzzle
PHP cURL needs only the curl extension. Guzzle needs composer require guzzlehttp/guzzle.
Run it
Save it as curl.php and run php curl.php. Files named with -d @ or -F are read when it runs.
Why is -d a string, not an array?
An array in CURLOPT_POSTFIELDS makes PHP send multipart/form-data. A string keeps the body curl sends, byte for byte.
What happens to file uploads?
-F file=@path becomes new CURLFile with the file name and type curl sends. Without them PHP sends the full local path as the file name.
Is a gzip response decompressed?
Yes. --compressed becomes CURLOPT_ENCODING => '', which asks for every encoding PHP's curl supports and decodes the reply.
Can a $ in a token break the code?
No. Strings are single-quoted, or double-quoted with $ escaped when they hold control characters. Multi-line bodies become nowdoc blocks whose marker no line can end early.
Is my command sent anywhere?
No. Conversion runs in this tab. Copied commands often carry cookies and tokens, so treat the code like a password.
Request blocked?
Browser Use cloud browsers run a maintained Chromium fork with residential proxies.