Sign up free

cURL to Code Converter

Paste a curl command and get the same request as Python, JavaScript, PHP, Go, Java or C# code.

About cURL to Code Converter

A cURL to code converter turns the curl example from an API's documentation, or a request you grabbed with Copy as cURL in Chrome or Firefox developer tools, into code you can drop into a project. Paste the command as it is, quoted and split over several lines if need be, and pick Python requests, JavaScript fetch, Node.js axios, PHP cURL, Go net/http, Java HttpClient or C# HttpClient.

The method, headers and body carry over, and the converter understands -d and the other --data options, --json, -F form fields, -u basic auth, -b cookies, -A user agent, -e referer, -G for sending data in the query string, -k, -L and --compressed. Requests copied from a browser often contain cookies and login tokens. Because the conversion runs in your browser, those never reach our server, but remove them before you share the generated code. To send a request and look at the response, try the HTTP Request Tester.

How to use cURL to Code Converter

  1. 1
    Copy a curl command

    In your browser's developer tools, right-click a request in the Network tab and choose Copy as cURL, or take one from the API docs.

  2. 2
    Paste it in

    Quoted and multi-line commands work as they are.

  3. 3
    Pick a language

    Choose Python, JavaScript fetch, Node.js axios, PHP, Go, Java or C#.

  4. 4
    Copy the code

    Put it in your project and move any keys or tokens into your own config.

Why use Cubfile for this

  • Seven targets

    Python requests, fetch, axios, PHP cURL, Go net/http, Java HttpClient and C# HttpClient.

  • Browser-ready

    Reads the quoted, multi-line commands that Chrome and Firefox copy.

  • Common flags

    Headers, data, --json, forms, basic auth, cookies, user agent, referer, -G, -k, -L and --compressed.

  • Secrets stay local

    Cookies and tokens in the command are never uploaded.

FAQ

cURL to Code Converter: questions and answers

How do I convert a curl command to Python?
Paste the command and choose Python. You get code that uses the requests library, with the method, headers, data and cookies from the command. Model classes for the JSON the API returns can be generated with JSON to Code.
How do I copy a browser request as a curl command?
Open developer tools with F12, go to the Network tab, right-click the request and choose Copy as cURL. Paste the result here unchanged.
Which curl options are supported?
The method (-X), headers (-H), -d and the other --data options, --json, -F, -u, -b, -A, -e, -G, -k, -L and --compressed.
Is it safe to paste a command with cookies or tokens?
The conversion happens in your browser, and nothing is sent to our server. Still, take session cookies and tokens out before you share the code with anyone.
Can I send the request from here?
Enter the same method, URL, headers and body in the HTTP Request Tester to send it and see the status, headers and response body.
Share cURL to Code Converter with a friendIt runs in any browser, and they can try it without signing up.

Related tools

HTML HTML FormatterIndent messy HTML so it’s easy to read.
JS JavaScript FormatterBeautify minified or messy JavaScript.
HEX Color ConverterConvert colors between HEX, RGB, HSL and CMYK, and check contrast.
CRON Cron Expression GeneratorBuild cron expressions and see the next run times in plain words.
CSS CSS FormatterTurn minified CSS into neat, readable rules.
CSS CSS MinifierMinify CSS to load faster.
HTML HTML MinifierShrink HTML by removing comments and extra whitespace.
HTTP HTTP Request TesterSend GET, POST and other requests to a public API and read the response.