Convert cURL to Laravel

Paste any curl command and get PHP code you can drop into a Laravel project. Guzzle-based HTTP client wrapped by Laravel's Http facade. Runs entirely client-side.

Quick answer

To convert a cURL command to PHP, paste it into the Toolpaper workbench below. It parses the command in your browser and emits idiomatic PHP code — headers, query string, request body, authentication (Bearer, Basic, API key), and cookies are all wired up automatically. No data is uploaded; conversion is fully client-side.

InputcURL command
MethodPOST·Headers1·Body40 B· Chars 132
OutputPHP · curl(ext-curl)
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.example.com/users");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"name\":\"Ada\",\"email\":\"ada@example.com\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Inspect

Example

A representative curl command for this scenario. Paste your own above to convert an exact match.

curl input
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"Ada","email":"ada@example.com"}'

Implementation notes

  • Generated code uses the ext-curl primitive that fits Laravel's idioms — you can drop it into a controller, action, or service.
  • Errors and timeouts propagate naturally so you can wrap the call in Laravel's middleware and observability layer.
  • Environment variables replace inline secrets when you run the output through the Clean panel first.

Common mistakes

  • Blocking a request-scoped Laravel handler on a slow upstream — always set a timeout in the generated call.
  • Recreating an HTTP client per request instead of reusing a module-level one — kills keep-alive performance.
  • Leaking request-scoped headers (auth, tracing) to upstream calls — the generator only forwards what you paste.

Common questions

Which PHP library does the Laravel output use?
ext-curl, because it's the idiomatic choice inside Laravel. Switch libraries in the language dropdown any time.
Can I use this in a serverless function?
Yes. The generated code is a plain PHP function; deploy it on Laravel's serverless target of choice.
Is any data sent to Toolpaper's servers?
No. Parsing and code generation run entirely in your browser.

Full PHP reference on the cURL to PHP hub, or open the main converter for all 18 targets.