Processed on our server. Your input is sent to our server to produce the result. Uploaded files are not kept, and nothing is sold or shared; our privacy policy lists what is logged.
Conversion runs on our server (the underlying parser needs it) but your command is processed transiently and never logged or stored - if it contains a real API key or token, consider swapping in a placeholder before converting.
Convert curl Commands to Code
The Tools Kit's free curl to Code Converter turns a curl command into a ready-to-use HTTP request in Python, JavaScript, Node.js, Go, PHP, Ruby, Java, C#, Rust or Swift. Paste the example from an API's documentation, or a request you copied from your browser's dev tools, and get the same method, URL, headers and body written for the HTTP client your project already uses.
Whether you need to convert curl to Python requests, turn curl into a JavaScript fetch call, or translate a curl example into Go, the converter handles the flag-by-flag translation so you do not have to work out where each header and body field belongs.
How to Use the curl Converter
- 1
Paste the curl command
Paste the full command into the curl command box, including the URL and any -X, -H, -d, -u or -F flags. Multi-line commands joined with backslashes are fine.
- 2
Choose a target language
Pick Python (requests), JavaScript (fetch), Node.js, Go, PHP, Ruby, Java, C#, Rust or Swift from the Target language menu.
- 3
Click Convert
The command is parsed and translated into an equivalent HTTP request in the language you picked. If it cannot be parsed, an error explains why.
- 4
Copy the generated code
Use the Copy button to take the snippet into your project, then replace any placeholder tokens with real values from your own config.
The converter only writes code. It never sends the request to the URL in your command, so you can safely convert calls to production endpoints and run them later yourself.
curl to Python Requests: A Worked Example
The command the tool opens with sends a JSON body to create a user:
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Alice"}'With Python (requests) selected, Convert produces this (a short commented-out alternative using the raw string body is also included in the output):
import requests
headers = {
'Content-Type': 'application/json',
}
json_data = {
'name': 'Alice',
}
response = requests.post('https://api.example.com/users', headers=headers, json=json_data)Because the Content-Type header says JSON, the -d string is parsed into a Python dictionary and passed as json= rather than as a raw string. If your body will not parse, check it first with the JSON formatter, which reports the parser error for invalid JSON. Choosing JavaScript (fetch) instead gives a fetch() call with method: 'POST', a headers object and body: JSON.stringify(...).
How curl Flags Map to Code
Most curl commands in API docs use a handful of flags. Here is what each one becomes in the generated code, using Python as the reference:
| curl flag | What it does and how it converts |
|---|---|
| -X / --request | Sets the HTTP method, such as POST, PUT, PATCH or DELETE; curl defaults to GET, or POST when a body is sent |
| -H / --header | Adds one request header, such as Content-Type or Authorization; each becomes an entry in the generated headers |
| -d / --data | Sends a request body; a JSON body with a JSON Content-Type becomes a native object in languages that support it |
| -u / --user | HTTP Basic authentication as user:password; in Python it becomes the auth argument |
| -F / --form | A multipart form field; file=@name uploads a file, which Python maps to the files argument |
| -k / --insecure | Skips TLS certificate verification; in Python it becomes verify=False, which you should not ship to production |
A query string on the URL, such as ?page=2, is split into a separate params dictionary in Python. If a parameter value contains spaces or symbols, the URL encoder shows how it should be percent-encoded. A -u user:password flag is plain HTTP Basic auth, which is just the pair Base64-encoded in an Authorization header; you can see that value with the Base64 encoder.
Copy as cURL From Browser Dev Tools
Chrome, Edge and Firefox can export any request from the Network tab as a curl command: right-click the request and choose Copy as cURL. Pick the bash variant where offered. The converter parses commands with a bash parser, so the Windows cmd variant, which escapes quotes with the ^ character, comes out garbled. Copied requests often carry cookies and authorization headers, so trim the headers you do not need before converting.
When a captured request carries a bearer token, the JWT decoder shows its claims and expiry (paste the token without the Bearer prefix), which helps when a converted request fails with a 401. If the converted code runs but the server returns an unexpected code, look it up in the HTTP status codes reference.
Is It Safe to Paste API Keys?
Unlike most tools on this site, this converter does not run fully in your browser. It uses the open-source curlconverter library, which depends on a native bash parser, so the command is sent to our server, converted, and returned. Only a usage event recording whether the conversion succeeded is kept; the command text is not stored. Even so, treat any converter the way you would treat a shared screen: swap real API keys, session cookies and tokens for placeholders such as YOUR_API_KEY before converting, then load the real secret from an environment variable in your code. For APIs that sign requests, the HMAC generator lets you check a signature by hand.
Common uses
- Turning a curl example from API documentation into working code in your project's language
- Reproducing a browser request captured with Copy as cURL as a Python or Node.js script
- Learning what each flag in an unfamiliar curl command actually does
- Prototyping a REST API call without writing HTTP client boilerplate by hand
- Porting the same request between languages, for example from Python to Go
More utilities for working with APIs, encodings and data formats are collected in the developer tools section of The Tools Kit.
Frequently Asked Questions
Paste the curl command, choose a target language from the menu, and click Convert. The tool parses the method, URL, headers, body, authentication and form fields and writes the same request in Python, JavaScript, Node.js, Go, PHP, Ruby, Java, C#, Rust or Swift. Copy the result with one click.
Choose Python (requests) as the target. Headers become a headers dictionary, a JSON -d body sent with a JSON Content-Type becomes the json argument, a plain body becomes data, -u user:pass becomes auth, -F file uploads become files, and a query string becomes a params dictionary. Install requests with pip and the snippet is ready to run.
Choose JavaScript (fetch). The output is a fetch() call with the URL, a method option, a headers object and a body; a JSON body is written as JSON.stringify of the object. Pick Node.js instead if you want code aimed at a server-side Node script.
Ten targets are available: Python (requests), JavaScript (fetch), Node.js, Go, PHP, Ruby, Java, C#, Rust and Swift. Each one produces a standalone snippet using that language’s usual HTTP client.
No. It only translates the command into source code; it never sends the HTTP request to the URL in your command. You run the generated code yourself.
The parsing library needs a native bash parser, so conversion runs on our server rather than in your browser. The command is processed only to produce the code; just a usage event (success or error) is recorded, not the command text. As a precaution, replace real API keys, cookies and bearer tokens with placeholders before converting.
Yes. In the Network tab, right-click a request and use Copy as cURL, choosing the bash variant if your browser offers one. The Windows cmd variant escapes characters with ^ and is not understood by the bash parser, so it produces broken output.
The command must start with curl and use valid bash quoting. Common causes are a missing closing quote, a stray character after a backslash line break, a command copied in Windows cmd format, or a prompt symbol such as $ pasted in front of curl.
It handles the flags real API examples use: method, headers, data and JSON bodies, query strings, basic auth, multipart form uploads and options such as --insecure. curl has hundreds of options, and rare ones may have no equivalent in the target language, so review the output before using it.
curl is installed almost everywhere and is not tied to any programming language, so documentation uses it to show exactly which method, headers and body to send. A curl converter turns that neutral example into code for the language your project actually uses.
Reviewed by Raja Jahangir · Last reviewed: October 7, 2026
How do you convert a curl command to code?
To convert a curl command, paste it, including any -X, -H, and -d flags, choose a target language, and click Convert. Output is available for Python (requests), JavaScript (fetch), Node.js, Go, PHP, Ruby, Java, C#, Rust, and Swift. The command is parsed on the server with the curlconverter library, which needs a native bash parser.
How do you convert curl to Python requests?
Choose Python (requests) as the target language and the curl flags map directly: -X POST becomes requests.post, each -H header goes into a headers dictionary, -d or --data becomes the data or json argument, and -u becomes auth. The generated snippet is ready to run once the requests package is installed with pip.
