Convert curl commands to Python, JavaScript, Ruby, and PHP code. Free curl converter that parses headers, auth, and request bodies instantly.
You need a curl command and a target language. That is it.
This curl converter runs entirely in your browser. Nothing is sent to a server, so you can safely paste commands that include API keys, authentication tokens, or internal URLs.
Curl is a command-line tool for making HTTP requests. It ships with macOS, most Linux distributions, and recent versions of Windows. When a developer says "give me a curl for that endpoint," they mean a single-line command that defines a URL, HTTP method, headers, and body. Everything needed to reproduce a request.
API documentation frequently provides curl examples because they are language-agnostic. A curl command tells you exactly what the request looks like without assuming you use Python, JavaScript, or any other language. The catch is that translating a curl command into working code by hand takes longer than it should, especially when the command includes multiple headers, authentication, and a JSON body.
A curl converter automates that translation. Paste the command, pick a language, and get code that is ready to run.
This tool parses the most commonly used curl flags. Here is a quick reference of what each flag does and how the converter handles it.
| Flag | Long form | Purpose |
|---|---|---|
| -X | --request | Sets the HTTP method (GET, POST, PUT, DELETE, PATCH) |
| -H | --header | Adds a request header (repeatable for multiple headers) |
| -d | --data | Sends a request body; implies POST if no method is set |
| -u | --user | Sets HTTP Basic Authentication (user:password) |
| -b | --cookie | Sends cookies with the request |
| -A | --user-agent | Sets the User-Agent header |
| -L | --location | Follows HTTP redirects automatically |
| -k | --insecure | Skips SSL certificate verification |
| -F | --form | Sends multipart form data |
Flags like --data-raw and --data-binary are treated identically to -d. If no -X flag is provided but a body is present, the converter defaults to POST.
This converter supports four languages. Each has a dedicated page with language-specific examples and guidance:
requests library code with headers, auth tuples, and body parameters.curl_* function calls that mirror libcurl options directly.Net::HTTP code from the standard library with no gem dependencies.The most common source is browser DevTools. In Chrome, Firefox, or Edge, open the Network tab, find the request you want to reproduce, right-click it, and select "Copy as cURL." This gives you a curl command with every header the browser sent, including cookies, authorization tokens, and content negotiation headers.
API documentation is the second major source. Services like Stripe, Twilio, GitHub, and most REST APIs include curl examples for every endpoint. Pasting these into a curl converter saves you from manually translating the example into whatever language your project uses.
Terminal history is the third source. If you built a working curl command through trial and error in your terminal, converting it to code preserves the exact request that worked: headers, body, and all.
Most curl conversion errors come from quoting issues. Curl commands copied from documentation sometimes use "smart quotes" (curly quotes) instead of straight quotes. This tool handles straight single and double quotes. If the conversion fails, check that your quotes are standard ASCII characters.
Line continuations are another common problem. Multi-line curl commands use a backslash (\) at the end of each line to continue the command on the next line. This tool joins those lines automatically, but if the backslash is missing or there are extra spaces, the command may not parse correctly.
Commands copied from web pages sometimes include invisible Unicode characters or zero-width spaces. If a command looks correct but fails to parse, try retyping the URL or header values manually.
Curl is the right choice for simple API calls: fetching data from a REST endpoint, posting a JSON payload, or checking a URL's response headers. If the request is stateless and doesn't require JavaScript rendering, curl (or code generated from a curl command) is the fastest path.
When the target page relies on JavaScript to load content, requires multi-step interaction (clicking buttons, filling forms, navigating between pages), or needs a full browser session with cookies and state, a browser automation tool like Browserbeam is a better fit. Browser automation gives you a real browser context where you can extract structured data from dynamically rendered pages.
Many developers start with curl to test an endpoint, then move to browser automation when the task requires more than a single HTTP request. This curl converter helps with the first step: turning an ad-hoc curl command into reusable code.
A curl converter takes a curl command and translates it into equivalent code in a programming language like Python, JavaScript, Ruby, or PHP. It parses the URL, HTTP method, headers, body, and authentication from the curl command and generates code that makes the same request using that language's HTTP client.
Paste your curl command, select "Python," and click Convert. The output uses the requests library. See the full guide on the curl to Python page.
No. All parsing and code generation happens in your browser. Nothing is transmitted to any server. You can safely paste curl commands that contain API keys, bearer tokens, or internal URLs.
Yes. Select "JavaScript" and click Convert. The output uses the Fetch API with async/await syntax. See the full guide on the curl to JavaScript page.
The converter parses -X (method), -H (headers), -d / --data / --data-raw (body), -u (basic auth), -b (cookies), -A (user agent), -L (follow redirects), -k (skip SSL), and -F (form data).
Open DevTools (F12), go to the Network tab, find the request you want, right-click it, and select "Copy" then "Copy as cURL." This copies a complete curl command with all headers and cookies the browser sent. Paste it into this tool to convert it to code.
The most common causes are curly (smart) quotes instead of straight quotes, missing line continuation backslashes in multi-line commands, or invisible Unicode characters copied from web pages. Try retyping the problematic parts or converting smart quotes to standard ASCII quotes.
This tool currently supports Python, JavaScript, Ruby, and PHP. These cover the most searched language targets for curl conversion. Additional languages may be added in the future based on demand.
Structured page data instead of raw HTML. Your agent processes less, decides faster, and costs less to run.