Convert cURL Commands to PHP
A cURL command copied from a terminal or a browser's developer tools can be turned into PHP request code without retyping headers, cookies or form fields.
This page provides an input box for the cURL command and a PHP output panel with a copy-to-clipboard button. It is a code translator, not a request runner: the PHP snippet is produced for you to review and run in your own PHP environment.
How the converter works
Paste the full cURL command into the input area. The tool reads the URL, method, headers, cookies and body fields, then renders an equivalent PHP cURL snippet in the output panel. Use the copy button to move the snippet into your editor. The default sample input is curl example.com, which is a good first test to confirm the tool is producing output before you paste a longer request.
When to use the converter
Use the converter when you already have a working cURL command and need a PHP starting point. It saves time on long requests with many headers or a JSON body. Skip it when you need to design the request from scratch or when the cURL command uses features PHP's cURL extension does not support; in those cases write the PHP code directly and test it against the target endpoint.
cURL input to PHP output: what to check
After conversion, verify these parts of the generated snippet before running it:
- URL and method: confirm the HTTP verb matches the original command.
- Headers: check that authorization, content-type and cookie headers survived the conversion.
- Body: confirm JSON or form-encoded payloads are passed as a string or array in the expected PHP form.
- Options: PHP cURL options such as CURLOPT_RETURNTRANSFER and CURLOPT_FOLLOWLOCATION may need to be added by hand depending on your use case.
Getting a cURL command from your browser
Most browsers can copy a request as a cURL command from the Network panel of their developer tools. The exact menu label varies by browser. Guides are available for Chrome, Safari and Firefox if you are not sure where to find the copy option.
Going further with PHP web scraping
If you want to build a full scraping workflow in PHP rather than convert a single request, a longer PHP web scraping tutorial covers request handling, parsing and common pitfalls.
Other cURL converters
The same input can be converted to other languages and runtimes, including CFML, Dart, Elixir, Go, Java, JavaScript Fetch, JSON, MATLAB, NodeJS with Axios, NodeJS with fetch, NodeJS with Request, Python, R and Rust. Use the matching converter if your target project is not PHP.
Frequently asked questions
What does the converter output?
It outputs PHP cURL code that corresponds to the cURL command you paste. The output is a code snippet for you to review and run in your own PHP environment; the tool does not execute the request.
What is the default input?
The input box starts with curl example.com, a short sample you can replace with your own command.
How do I get a cURL command from my browser?
Open the browser's developer tools, go to the Network panel, right-click the request you want and choose the copy-as-cURL option. The exact wording differs between Chrome, Safari and Firefox; dedicated guides cover each browser.
Does the converter send the request for me?
No. It only translates the cURL command into PHP code. You run the resulting snippet yourself, so you control credentials, environment and any follow-up requests.