FREE TOOL

curl to PHP Converter

Paste a curl command, get working PHP cURL-extension code — every option mapped to its curl_setopt flag. Runs in your browser, no signup.

Conversion runs entirely in your browser — the command (and any tokens or cookies in it) is never sent to a server. Tip: DevTools Network tab → right-click a request → Copy as cURL.

Scraping a real site? Skip the blocks

Hand-copied curl headers go stale, and sites still block datacenter IPs. The same request through the WebScraping.AI API gets rotating proxies, headless Chrome rendering, and unblocking in one call — your custom headers and cookies are forwarded via the headers parameter:

2,000 free API credits · No credit card required

What the generated PHP code does

PHP's cURL extension wraps the same libcurl as the command line, so the mapping is nearly one-to-one: -H headers become a CURLOPT_HTTPHEADER array, -d bodies go to CURLOPT_POSTFIELDS (as a string — passing an array would silently switch the request to multipart), -F uploads use an array with CURLFile, -u maps to CURLOPT_USERPWD, -x to CURLOPT_PROXY, -L to CURLOPT_FOLLOWLOCATION, and -k to disabling CURLOPT_SSL_VERIFYPEER. CURLOPT_RETURNTRANSFER is always set so the response comes back as a string instead of being echoed.

Prefer a higher-level client? The same request in Guzzle is usually shorter — but the cURL extension ships with almost every PHP install, which is why converted snippets target it.

Frequently asked questions

How do I convert a curl command to PHP?

Paste the command into the converter above — it outputs PHP cURL-extension code instantly, in your browser. Headers, cookies, POST bodies, basic auth, proxies, redirects, and file uploads are mapped to their curl_setopt flags. Nothing you paste is sent to a server.

Should I use the cURL extension or Guzzle?

The cURL extension needs no dependency and mirrors the command line exactly, which makes converted commands easy to verify. Guzzle gives you a cleaner API, PSR-7 requests, middleware, and async — worth it in application code. The generated cURL snippet ports to Guzzle in a few lines.

Why does my POST body arrive as multipart instead of form-encoded?

A PHP quirk: passing an array to CURLOPT_POSTFIELDS sends multipart/form-data, while a string sends application/x-www-form-urlencoded. The converter emits the body as a string for exactly that reason — only -F uploads use the array form with CURLFile.

The PHP code gets a 403 but curl from my machine works — why?

Your server's IP likely has datacenter reputation, and anti-bot systems also check TLS fingerprints and run JavaScript challenges that plain cURL can't pass. The WebScraping.AI API routes the same request through rotating proxies and real headless Chrome — one HTTP call from PHP, no extension changes.

Related

PHP code ready? Make it unblockable.

Same request, plus rotating proxies, headless Chrome, and JS rendering — one API call from PHP.

Icon