cURL to PHP Guzzle Converter
Convert curl commands to PHP code using Guzzle. Paste a command and the Guzzle snippet appears instantly — everything runs in your browser.
- Instant ConversionCode updates as you type
- Multiple Languages40 languages, 61 libraries
- 100% Client SideYour data stays private
How to use this tool
Steps for using the cURL to Code.
- Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
- Paste it into Enter cURL command. The PHP Guzzle code appears instantly; other PHP libraries (cURL, Requests) are in the tabs above the code.
- Set up: Install with
composer require guzzlehttp/guzzle. - Run it: Run
php request.phpfrom the project with the Composer autoloader. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no Guzzle equivalent.
Example
GET with headers → PHP Guzzle
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'<?php
require __DIR__ . '/vendor/autoload.php';
$client = new GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.example.com/v1/users?page=2', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer YOUR_TOKEN',
],
'http_errors' => false, // return 4xx/5xx responses instead of throwing
]);
echo $response->getStatusCode() . PHP_EOL;
echo $response->getBody() . PHP_EOL;Common use cases
- Laravel and Symfony applications
- API SDKs
- Composer-based projects
Converting curl to PHP Guzzle
Guzzle is the most widely used PHP HTTP client, used by Laravel's HTTP client among others.
The converter reads the curl command the way curl does — the method (-X), headers (-H), request bodies (-d, --data-raw, --json, -F), query strings, basic auth (-u) and cookies — and writes the equivalent Guzzle code. Options that have no Guzzle equivalent are listed under the editors rather than silently dropped.
Other libraries for PHP, each with its own page: cURL, Requests.
Limitations
- The code is a starting point: add timeouts, retries and error handling for production use.
- Secrets in the curl command are copied into the code — move them to environment variables before committing.
Frequently asked questions
Why http_errors => false?
Guzzle throws on 4xx/5xx by default; this returns the response like curl does.
How do I send JSON with Guzzle?
Pass an array as the json option — Guzzle encodes it and sets the Content-Type.
Is my curl command sent to a server?
No. The conversion runs entirely in your browser, so tokens and passwords in the command never leave your device. Still, replace real secrets before sharing the generated code.