cURL to PHP
Paste a curl command and get PHP code using cURL — or pick any other language.
Paste a curl command above to generate code
How curl maps to PHP (cURL)
- →PHP's cURL extension mirrors the command line: CURLOPT_HTTPHEADER for -H, CURLOPT_POSTFIELDS for -d, CURLOPT_CUSTOMREQUEST for -X.
- →Values are written as single-quoted PHP strings, so a $ in a token or password isn't treated as a variable.
- →For -k / --insecure you'd set CURLOPT_SSL_VERIFYPEER to false — the converter leaves verification on on purpose.
Frequently asked
How do I convert curl to PHP?
Paste the command and pick PHP (cURL). The result uses curl_setopt_array with the URL, method, headers and body from your command.
Should I use Guzzle instead of PHP cURL?
Guzzle is nicer for bigger projects (PSR-7, middleware, retries). The plain cURL output has no dependencies and runs on any PHP install with the curl extension.