cURL to PHP Guzzle

Convert cURL commands into PHP Guzzle client code — json, form_params, multipart and auth options included.

Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.

PHP Guzzle code

  

About this tool

Guzzle is PHP's standard HTTP client, but translating cURL flags to its options array takes documentation-diving. This tool parses the command and writes the full Guzzle request: JSON bodies become 'json' =>, URL-encoded data becomes 'form_params', uploads become 'multipart', and -u becomes 'auth'.

Boilerplate (require + use statements) is optional so you can paste into existing code.

How to use it

  1. Paste the cURL command.
  2. Toggle boilerplate if you need a standalone script.
  3. Copy the generated PHP.
  4. Run it in any project with guzzlehttp/guzzle installed.

Useful ways to apply it

  • Implementing a third-party API from its cURL-only documentation.
  • Migrating shell-based integrations into a Laravel/Symfony app.
  • Generating consistent Guzzle snippets across a team.
  • Learning how cURL concepts map to Guzzle options.

Worked example

Example input

curl -X POST 'https://api.example.com/items' -H 'Content-Type: application/json' -d '{"name":"Ada"}'

Expected output

$client->request('POST', 'https://api.example.com/items', ['json' => ['name' => 'Ada']]);

Edge cases to check

  • Guzzle options differ from raw cURL flags.
  • Streaming uploads, client certificates and proxy options require application-specific review.
  • Never hard-code production bearer tokens into generated source.

Known limitations

The converter targets common Guzzle request patterns and does not cover every cURL transport feature.

How this tool was reviewed

Reviewed with methods, JSON/form bodies, headers and bearer authentication examples.

Last reviewed: September 3, 2026 · Maintainer: William

Standards and technical references

Frequently asked questions

Which body types are recognized?
JSON bodies map to 'json', application/x-www-form-urlencoded to 'form_params', and -F fields to 'multipart' with fopen() placeholders for @file references.
Is -k / --insecure handled?
Yes, it becomes 'verify' => false — with the reminder that you should only disable TLS verification in development.
Which Guzzle version is targeted?
The generated code uses the request() method compatible with Guzzle 6 and 7.

Privacy

Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.