Developer Tools
cURL to PHP Converter
Convert a curl command to PHP. Pick native php-curl with curl_setopt_array, Guzzle, or the Laravel Http client. Runs locally in your browser.
The curl command is parsed locally in your browser. Tokens, headers, auth values, and request bodies never leave your device.
What gets converted
- Method and URL
- -X / --request sets the method explicitly. Without it, a body forces POST and -G with -d folds the data into the URL and forces GET. For Guzzle, query strings with two or more pairs become a 'query' array.
- Headers and auth
- Every -H / --header becomes an entry in CURLOPT_HTTPHEADER, the Guzzle 'headers' option, or Laravel withHeaders(). -u / --user maps to CURLAUTH_BASIC, the Guzzle 'auth' option, or withBasicAuth().
- JSON and form bodies
- -d values that parse as JSON become a PHP array passed as json_encode for php-curl, the Guzzle 'json' option, or Laravel post($url, [...]). Form-urlencoded bodies become a 'form_params' array for Guzzle and asForm() for Laravel.
- Multipart and TLS
- -F parts use CURLFile for php-curl, the Guzzle 'multipart' option, or Laravel attach(). -k / --insecure maps to CURLOPT_SSL_VERIFYPEER => false, the Guzzle 'verify' => false option, or Laravel withoutVerifying().
How to use
- Paste a curl command into the input area, or click Load sample to start from a worked example.
- Pick an output style: php-curl for native curl_setopt_array, Guzzle for guzzlehttp/guzzle, or Laravel Http for the Illuminate facade.
- Review the parsed method, URL, header count, and body type in the summary card to confirm the curl was understood correctly.
- Use Copy code to grab the generated PHP. Replace any @file placeholders in multipart uploads with the real file path.
- If any curl flags do not map to PHP, the warning panel lists what was ignored so you can adjust the command and try again.
About this tool
cURL to PHP Converter ports a curl command into idiomatic PHP without leaving the browser. The parser uses a real POSIX-style shell tokenizer (literal single quotes, double quotes with backslash escapes, ANSI-C $'...' quoting, backslash-newline continuations, and glued short flags like -XPOST) so commands copied from terminal history, Postman, the browser DevTools Copy as cURL menu, or API documentation all parse the same way. Once the request is parsed, the tool emits three target styles that match how PHP developers actually search and write HTTP code. The php-curl output uses curl_init and curl_setopt_array, which is the form most legacy projects, shared-host scripts, and Stack Overflow answers use, and it does not require Composer. The Guzzle output uses GuzzleHttp\Client with the json, form_params, multipart, query, headers, auth, verify, and decode_content options, which is the de facto third-party client for modern PHP. The Laravel Http output uses Illuminate\Support\Facades\Http with the chained withHeaders, withBasicAuth, withBody, asForm, attach, and withoutVerifying helpers that ship with Laravel and Lumen. Headers, basic auth (-u user:pass), cookies (-b), user-agent (-A), and referer (-e) are all carried through. JSON bodies are detected by sniffing the data argument and printed as a real PHP array literal instead of a quoted string, so the code is readable and editable. Form-urlencoded bodies are split back into name and value pairs for the form_params or post helpers. Multipart -F parts are emitted as CURLFile (php-curl), the Guzzle multipart option, or Laravel attach, with file references marked with @ pointed to the original path. -G with -d folds the data into the query string. --compressed and -k / --insecure map to the correct option in each target. The tool runs entirely in your browser; the pasted command, headers, auth values, cookies, and JSON bodies never leave your device.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
cURL Command Builder
Form-driven builder that emits curl, PowerShell, HTTPie, wget, fetch, and raw HTTP/1.1.
Open tool
DevelopercURL to Fetch Converter
Convert curl into fetch, Node fetch, axios, or XHR JavaScript.
Open tool
DevelopercURL to Python Converter
Convert curl into Python requests, http.client, or urllib code.
Open tool
DeveloperJSON to PHP Array Converter
Turn any JSON value into an idiomatic PHP associative or numeric array.
Open tool
DeveloperPHP Serialize and Unserialize
Parse PHP serialize() output and re-encode JSON into a portable PHP serialize string.
Open tool
DeveloperHTTP Headers Parser
Parse, classify, and decode HTTP headers, with a missing security headers audit.
Open tool