Skip to content
snowkitDev

Convert cURL to JavaScript fetch, instantly

Paste a cURL command copied from your browser or API docs and get ready-to-run fetch code.

cURL to code

Paste a command and pick a language.

Try
Code

              

    Nothing you paste is sent anywhere.

    Your command, tokens included, never leaves this page. Paste a cURL command and get ready-to-use code in JavaScript, Python, Go or PHP. It is free and runs in your browser.

    How to convert a cURL command

    1. Paste your command into cURL command, or press one of the examples: POST JSON, Upload a file, Basic auth or GET with query.
    2. Choose the language under Code: JavaScript, Python, Go or PHP.
    3. Read the converted code and press Copy code.

    What's supported

    Methods (-X), headers (-H), request bodies (-d, --data-raw, --data-binary, --data-urlencode, --json), forms and file uploads (-F), basic auth (-u), bearer tokens, cookies (-b), -G query strings, redirects (-L), -k, --compressed and -I. Multi-line commands with backslashes work, including ones copied from Chrome, Firefox and Edge.

    Copying a request from your browser

    Open the developer tools, go to the Network tab, right-click a request and choose Copy, then Copy as cURL (bash). Paste it here to get working code with the same headers.

    JSON bodies

    When the body is JSON, it's written as a real object in JavaScript and Python rather than a string, so it's easy to edit.

    Tips

    • Treat tokens and cookies in a copied command as passwords. Replace them with variables before sharing your code.
    • Test the converted code with a small request before using it in a real program.
    • Some options only affect cURL itself and have no direct equivalent, so read the result and adjust.
    • Format the JSON body first with the JSON tools if it is hard to read.

    Who uses it

    Developers testing an API from documentation examples, students following a tutorial in a language the example does not use, and freelancers moving a working request into a script. Related: the HTTP header checker.

    Questions

    Is my command or token sent anywhere?

    No. The conversion happens in your browser. The request is not sent.

    Does it run the request?

    No. It only converts the command into code.

    Why does my command fail to convert?

    Check for unmatched quotes and make sure the command starts with curl. Commands from Windows command prompts use different quoting and may need tidying.

    Where to next

    Carry on with what you just made, still on your device.

    More from Snowkit