How do I convert a cURL command to code?
A cURL converter turns a curl command into code for another language or library. This cURL converter outputs fetch, axios, Node.js, Python requests, PHP, Go, HTTPie or PowerShell, and parses the command locally in your browser.
Browser DevTools and API documentation both give you requests as curl commands. To use the request in code, you have to translate the method, headers, body, authentication and flags by hand. The converter tokenises the command like a shell, reads its options and generates the equivalent code.
Use Copy as cURL in the network tab of your browser, paste it in, and pick a target: JavaScript fetch, axios, Node.js, Python requests, PHP, Go, HTTPie or PowerShell. Headers, JSON bodies, form data, basic auth, cookies and common flags are carried across.
Check the output before running it: the command may contain tokens and cookies, so treat the result like a secret. The tool runs locally and does not send your command anywhere. For a shell-free view of a response, use the [HTTP Headers Viewer](/tools/http-headers).
Page updated .
How to use the cURL to Code Converter
- Copy a request as cURL from your browser network tab or docs.
- Paste it into the box and choose the target language.
- Copy the generated code and remove any secrets before sharing.
Examples
curl -X POST https://api.example.com/items -H "Content-Type: application/json" -d '{"name":"x"}'fetch call with method POST, the header and a JSON string body
curl -u user:pass https://example.com
An Authorization: Basic header or the library auth option
Tips
- Strip cookies and authorization headers from the command before you share the code.
- Use -d with JSON and the right Content-Type header so the body is parsed as JSON.
- If the output sends form data, check whether you meant multipart or urlencoded.
Specs & limits
- Targets
- fetch, axios, Node.js, Python requests, PHP, Go, HTTPie, PowerShell
- Parsing
- Shell-style tokenising
- Input
- A curl command
- Execution
- None; converts only
- Processing
- In your browser
Troubleshooting
›Parse error
Cause: Unbalanced quotes in the command.
Fix: Check quotes and escape characters.
›Unsupported flag
Cause: The option has no equivalent.
Fix: Add it by hand in the generated code.
›Body not sent as JSON
Cause: Content-Type header missing.
Fix: Add the JSON header.
Frequently asked questions
›Which languages can it generate?
JavaScript fetch, axios, Node.js, Python requests, PHP, Go, HTTPie and PowerShell.
›How do I get a curl command from my browser?
Right-click a request in the network tab and choose Copy as cURL.
›Does it run the request?
No. It only converts the command to code.
›Are my tokens sent anywhere?
No. Parsing is local. Remove secrets before sharing the output.
›What curl options are supported?
Method, headers, data, form data, user credentials, cookies, redirects and common flags.
›Why does the code differ from curl behaviour?
Some flags, such as --compressed or timeouts, have no direct equivalent in every library.