cURL converter

Convert cURL to PHP

Paste a cURL command and get PHP code using Guzzle — the standard HTTP client in modern PHP, bundled into Laravel, Symfony HttpClient bridges, and most SDKs on Packagist. The output is PSR-7 compatible and reads cleanly inside any framework or plain PHP project.

Headers, query parameters, JSON or form-encoded bodies, basic auth and bearer tokens from your cURL command are all written into the Guzzle request options array. The snippet uses Guzzle's exception model so 4xx and 5xx responses surface as catchable exceptions rather than silent failures.

Free demo trial • No credit card required • Setup in <2 minutes

What is cURL to code conversion?

Convert cURL commands into clean, production-ready code for any programming language. Our tool automatically parses headers, methods, data payloads, and authentication from your cURL commands and generates equivalent code with perfect syntax.

Perfect for developers who work with APIs, need to convert browser network panel exports, or want to quickly prototype API integrations. Instead of manually translating cURL commands, get instant, accurate code that follows language best practices and includes proper error handling.

Use the converted code with Scrappey's API for reliable web scraping on JavaScript-heavy and modern websites. All conversions happen instantly with no registration required and complete privacy protection.

cURL Converter Visual

Convert cURL to code

Paste your cURL command and get instant code conversion

cURL Command

Complete the verification to convert your cURL command

PHP Code

Enter a cURL command to see the converted code...

Supported programming languages

Click any language to switch conversion target

Unlock Full Functionality Without Limits

Register for a free account to access all tools with unlimited usage and advanced features.

Register & Access Full Tools

Why use Scrappey for cURL conversion?

Fast, accurate, and perfect for any development workflow

Lightning Fast

Convert cURL commands to code in seconds. No waiting, no delays - just instant results with perfect syntax.

Multiple Languages

Support for 15+ programming languages including Python, Node.js, Java, PHP, Go, Ruby, C#, and more.

Privacy First

Your cURL commands are processed securely. No data stored, no tracking, complete privacy protection.

Perfect Syntax

Get production-ready code with proper syntax highlighting, error handling, and language best practices.

Accurate Conversion

Automatically parses headers, methods, data payloads, and authentication from complex cURL commands.

No Registration

Free to use with no registration required. Convert unlimited cURL commands instantly with no limits.

Perfect for

API Developers

Quickly convert API documentation examples from cURL to your preferred programming language. Perfect for integration testing and rapid prototyping.

QA Engineers

Transform browser network panel cURL exports into automated test scripts. Streamline your testing workflow with instant code generation.

Web Scraping

Convert browser network requests to code for automated data collection. Use with Scrappey for advanced request handling.

Rapid Prototyping

Quickly prototype API integrations by converting cURL commands from documentation or browser DevTools into working code.

How cURL to PHP works

The PHP output uses GuzzleHttp\Client with the request options array — headers, query, json, form_params, auth and proxy map one-to-one from the cURL flags. JSON bodies use json => [...], urlencoded bodies use form_params => [...], and multipart uploads use multipart => [...]. Guzzle throws GuzzleHttp\Exception\ClientException on 4xx and ServerException on 5xx by default, so the snippet uses try/catch. For projects that can't take a Composer dependency, the converter can also emit raw curl_setopt() code on request.

PHP code example

Realistic GET + POST with headers and a JSON body, written using Guzzle.

<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new Client(['base_uri' => 'https://api.example.com', 'timeout' => 30]);

// GET with headers and query params
try {
    $response = $client->get('/users', [
        'headers' => [
            'Authorization' => 'Bearer YOUR_TOKEN',
            'User-Agent'    => 'MyApp/1.0',
        ],
        'query' => ['page' => 1, 'limit' => 50],
    ]);
    $users = json_decode((string) $response->getBody(), true);
} catch (RequestException $e) {
    fwrite(STDERR, "GET failed: " . $e->getMessage());
}

// POST with JSON body
$created = $client->post('/users', [
    'headers' => [
        'Authorization' => 'Bearer YOUR_TOKEN',
    ],
    'json' => ['name' => 'Ada Lovelace', 'email' => '[email protected]'],
]);
echo $created->getStatusCode(), PHP_EOL;

cURL to PHP — FAQ

Does this converter handle cURL POST requests in PHP?

Yes. POST, PUT, PATCH and DELETE all work. The converter reads -X, --data, --data-raw, --data-binary, --data-urlencode and -F (multipart) and translates each into the right call shape — JSON bodies become language-native objects, urlencoded bodies become key/value pairs, and multipart bodies use the language's standard form-data approach.

How do I handle cookies in PHP with the converted code?

Pass 'cookies' => true to the Guzzle client constructor and it will use an in-memory CookieJar across requests on that client instance. For persistent cookies, pass a FileCookieJar with a path. If your cURL command sets cookies via -b or -H "Cookie: ...", the converter writes them into the PHP request headers verbatim. For session-style flows where cookies persist across requests, use a session object (see the example above) so the library tracks Set-Cookie responses automatically.

Can I use this with proxies in PHP?

Yes. The generated PHP snippet keeps your request structure intact, so adding a proxy is straightforward — set the standard proxy parameter for the library shown in the output. If you need rotating residential or datacenter proxies for reliable access to authorized targets, route the request through Scrappey instead of calling the target directly. With Guzzle, pass 'proxy' => 'http://user:pass@host:port' as a request option, or set it on the client constructor to apply to every request.

I cannot install Guzzle — can I get raw curl_setopt() PHP instead?

Yes. The default snippet uses Guzzle because it's the dominant choice in modern PHP, but the parsed cURL command also maps directly onto curl_init() / curl_setopt() / curl_exec(). Swap the import block for procedural cURL calls — headers become CURLOPT_HTTPHEADER, the body becomes CURLOPT_POSTFIELDS, and the method becomes CURLOPT_CUSTOMREQUEST.

Convert to other languages

Need the same cURL command in a different language? Use one of these converters:

footer-frame

Start building with Scrappey

Try It For Free. No Subscription Required. No Credit Card Required. Instant Set-Up. Your Free Trial Is Waiting For You!

Frequently asked questions

What is Scrappey.com?

Scrappey.com is a web scraping API that handles all the complex aspects of web scraping, such as handling dynamic content, rotating proxies, advanced request handling, headless browsers, and verification processing. It offers an all-in-one solution for extracting publicly available data from websites.

How does Scrappey.com work?

Scrappey.com provides a web scraping API that allows you to send requests to extract publicly available data from websites. It handles dynamic content and modern website complexity, including rotating proxies, advanced request handling, and verification processing. You can easily extract publicly available data from websites using their built-in features like headless browsers and AI-powered data extraction.

Can I customize the proxies used for scraping?

Yes, with Scrappey.com, you have the option to use Sticky Rotating Proxies for seamless scraping. Alternatively, you can also set your own proxies if desired.

Is there a free trial available?

Yes, Scrappey.com offers a free trial where you can try it out without a subscription or credit card. Instant setup is provided, so you can explore the full capabilities of the platform right away.

What happens if a request fails?

We only charge for successful requests. Failed requests are not counted towards your usage, so you only pay for what works.

I need to scroll or click on a button on the page I want to scrape

No problem, you can pass any JavaScript snippet that needs to be executed by using our JavaScript scenario parameter. This allows you to interact with dynamic content, scroll pages, click buttons, wait for elements, and perform any custom JavaScript actions before extracting the data.

What is the pricing structure for Scrappey.com?

Scrappey.com offers simple and transparent pricing: €0.20 per 1,000 direct HTTP requests and €1.00 per 1,000 full-browser requests. Residential proxies are included on both tiers — no separate proxy billing, no hidden fees, no complicated pricing tiers. You only pay for successful requests.

Are there any usage restrictions or limitations?

Scrappey.com provides scalable access for extracting publicly available data. Whether you need to extract data from a few pages or a large dataset of publicly accessible content, you can do so with flexible usage options. Please note that Scrappey.com only supports scraping publicly available data, and users must comply with applicable laws and website terms of service.

What support channels are available?

Scrappey.com provides various support channels for assistance. You can refer to their documentation, frequently asked questions section, blog, and uptime status page. Additionally, you can get in touch with them via email or join their Discord community for further support.

I'm not a developer, can you create custom scraping scripts for me?

We don't create custom scraping scripts, however we will gladly write some code snippets helping you to use our most powerful features: AI-powered data extraction and JavaScript scenario. Our documentation includes examples in multiple programming languages to get you started quickly.

What is a request and how are they counted?

Each API call to Scrappey counts as one request. Our pricing is based on successful requests. By default, JavaScript rendering is enabled, which allows you to extract data from modern websites with dynamic content. All features including proxies, challenge handling, and reliable web access handling are included in each request.

How fast is Scrappey's API and what if a site is hard to scrape?

Scrappey's API is optimized for fast response time, even when working with JavaScript-heavy websites and browser verification flows, where access is authorized. If other tools struggle with sites that use browser verification, Scrappey is designed to handle these workflows efficiently, ensuring reliable data retrieval. Our reliable web access handling, residential proxies, and intelligent retry logic work together to maximize success rates.