cURL to PHP

Paste a cURL command and convert it to PHP curl_init code in the browser. Headers, custom methods, and request bodies are mapped so you can paste the snippet into a script.

cURL to: Java JavaScript Python PHP C# Go

About cURL to PHP

Convert a cURL command to PHP online and get curl_init and curl_setopt calls you can paste into a script. This free cURL to PHP converter maps URL, custom method, headers, and POST fields so a shell command becomes PHP without a rewrite.

It suits Laravel jobs, WordPress integrations, and plain PHP clients that still use the curl extension. CURLOPT_RETURNTRANSFER is set so the body is a string. Errors from curl_exec raise a RuntimeException instead of failing silently.

Dollar signs in strings are escaped for PHP. Insecure SSL flags from -k are included when present so you can delete them for production. Pair this page with JSON to PHP if you also need the body as an array literal.

The conversion runs in your browser. Use this free cURL to PHP converter whenever you need curl_setopt code from a copied command.