cURL to PHP Guzzle Converter — Private & Offline
Paste a cURL command and get idiomatic Guzzle 7 code: $client->request() with a typed options array, 'json' for JSON bodies, 'body' for raw payloads, and 'auth' for basic credentials. The conversion runs entirely in your browser — private and offline.
Zero upload, ever
Parsing and code generation run in your browser — URLs, headers, and tokens never touch a server.
Live 100 ms conversion
Output updates as you type or paste, with one-keystroke copy via Cmd/Ctrl + Enter.
Guzzle-native output
json, body, and auth options chosen the way Guzzle documentation does.
Paste a cURL command to convert
cURL command
Paste a cURL command — idiomatic code appears here instantly, converted entirely in your browser.
Technical documentation
How cURL maps to Guzzle
Guzzle exposes almost everything through a single request method: $client->request($method, $uri, $options). The converter maps -X/--request to the method argument, the URL to $uri, every -H flag into the 'headers' array, data flags into 'json' or 'body', and -u into the 'auth' option — producing one declarative call with no boilerplate.
When the body is JSON (detected from Content-Type, the --json shorthand, or the payload's shape), it is parsed and emitted as a formatted PHP array under the 'json' option, which Guzzle serializes and content-types automatically. Anything else — form pairs, XML, plain text — is passed as a raw string under 'body' with the original headers intact.
Literals translated to PHP conventions
JSON values are rewritten to their PHP equivalents during conversion: true and false become lowercase true and false (PHP booleans are case-insensitive, but modern style is lowercase), null becomes null, and nested objects become associative arrays with => syntax.
Strings are emitted as single-quoted PHP literals with backslash and quote escaping applied, so the snippet never depends on double-quote interpolation — no accidental $variable interpolation from payload contents.
Running the generated PHP code
The snippet targets PHP 7.2.5+ with Guzzle 7, the version required to keep PSR-7 and PSR-18 contracts current. Install it with Composer: composer require guzzlehttp/guzzle. The output is a runnable script with a try/catch around RequestException, echoing the response body — paste it into a file and run php script.php.
Because the call uses a plain Client instance, it lifts cleanly into frameworks: Laravel and Symfony applications typically register a shared Guzzle client in a container and inject it — the options array transfers unchanged.
Auth, headers, and wire fidelity
Basic auth from -u or credentials embedded in the URL becomes the 'auth' => [username, password] option; Guzzle builds the Authorization header at runtime. Bearer tokens and API keys sent via -H pass straight into the headers array untouched, and when an explicit Authorization header exists the auth option is skipped to avoid conflicts.
Query strings are preserved verbatim in the URL, repeated -d flags are joined with & exactly as curl joins them, and --data-urlencode values are percent-encoded during conversion — so the emitted request matches what curl would have put on the wire.
Frequently asked questions
Is my cURL command uploaded to a server during conversion?
No. The converter is a static page that transpiles in your browser — commands with production tokens, cookies, or basic-auth credentials are never transmitted, stored, or logged.
Which Guzzle version does the generated PHP target?
Guzzle 7 on PHP 7.2.5 or newer. Install with composer require guzzlehttp/guzzle. The snippet also works unchanged when the client is injected via a framework container.
When does the output use 'json' versus 'body'?
'json' is emitted for valid JSON bodies with a JSON content type — as a nested PHP array Guzzle serializes for you. Everything else becomes 'body' with the raw string, preserving the original content type.
How is basic auth (-u) converted for PHP?
It becomes the 'auth' => [username, password] option. If your command already carries an Authorization header (for example a bearer token), that header is kept instead and the auth option is omitted.
Does the PHP output handle custom HTTP methods?
Yes — the method string from -X is passed directly to $client->request(), so PROPFIND, MERGE, or any verb your API defines works as-is.
Can I use the generated code in Laravel or Symfony?
Yes. The options array (headers, json, body, auth) transfers directly to a container-managed Guzzle client — copy the array into your service call and adjust error handling to your framework's conventions.