Search tools

Find a tool by name or what it does.

cURL to Fetch Converter

Paste a curl command and get the equivalent JavaScript, with the method, headers, body, and basic auth carried across.

Line continuations and quoted arguments are handled. The code updates live as you type, and nothing leaves your browser.

Output style

JavaScript

Your JavaScript will appear here.

How to convert a curl command to fetch

  1. Paste the curl command

    Drop in the whole command, including the backslash line breaks that browsers and API docs copy along with it.

  2. Pick the output style

    Choose a browser fetch snippet, an axios request config, or a runnable Node script that prints the response.

  3. Check the notes

    Any flag that has no equivalent in a JavaScript request is listed below the code instead of being dropped quietly.

  4. Copy the code

    Copy the generated JavaScript straight into your project.

Why use this tool

Reads the flags that matter

The request method, headers, data flags, basic auth credentials, form fields, and the URL are all parsed, including the combined forms like -XPOST.

Three output styles

Switch between a browser fetch snippet, an axios request config, and a Node script wrapped in an async function with a status check and console output.

JSON and form bodies

The body is read from the content type: JSON is pretty printed inside the request, key and value pairs become a URL encoded body, and everything else is passed through as text.

Basic auth becomes a header

Credentials passed with -u are encoded into an authorization header, so the generated request needs no extra setup.

Nothing is dropped silently

Flags with no JavaScript equivalent, such as compression and TLS options, are listed under the output so you can see exactly what was left out.

Quotes and line breaks handled

Single quotes, double quotes with escapes, and backslash line continuations are parsed the way a shell would, so a copied multi-line command works as is.

About this tool

A curl command is the lingua franca of API documentation, but it is not what you ship. This tool reads a pasted command and rebuilds it as JavaScript: the URL, the request method, every header, and the request body, in the shape your code actually needs. It updates live as you type, so you can paste, tweak a header, and watch the snippet change.

The parsing is done properly rather than by pattern matching a few common shapes. Arguments are split the way a shell splits them, so single quotes stay literal, double quotes honor their escapes, and a command copied across several lines with trailing backslashes is read as one command. Flags are understood in every form curl accepts: separate values, values glued to the flag, and long flags written with an equals sign. A data flag with no explicit method implies POST, repeated data flags are joined, credentials passed with -u become an authorization header, and -G moves the data onto the query string.

The body type is decided by the content type header. JSON is parsed and re-emitted as a readable object inside the request, form encoded pairs become a URL encoded body, and anything else is sent as a plain string. When there is data but no content type, the form encoded default that curl itself applies is added so the generated request behaves the same way. Anything the browser handles on its own, such as compression and redirects, is called out in a note rather than dropped without comment. Once you have a request, the URL parser breaks down the endpoint, query string parser inspects the parameters, and the JWT decoder reads a bearer token you are passing along.

Frequently asked questions

Which curl flags are supported?
The request method, headers, all the data flags including raw and binary variants, the JSON shortcut, form fields, user credentials, user agent, cookie, referer, and the URL. Redirect and compression flags are recognized and explained in a note, since a JavaScript request already handles both.
What is the difference between the three output styles?
The fetch style gives a browser-ready snippet with the request options inline. The axios style gives a single request config object. Node fetch wraps the same call in an async function with a status check and prints the parsed response, so you can paste it into a file and run it.
How does it decide between a JSON body and a form body?
From the content type header. A JSON content type means the data is parsed and re-emitted as an object, a form encoded content type turns key and value pairs into a URL encoded body, and anything else is passed through as text. When there is data but no content type, the form encoded default that curl applies is added for you.
What happens to flags it cannot convert?
They are listed under the code as ignored, with the exact flag names. Nothing is dropped without telling you, so you can decide whether a timeout, a proxy, or a certificate option needs handling somewhere else in your setup.
Does the generated code work in Node as well as the browser?
Yes. Pick the Node fetch style and you get a script built around the request function that recent Node versions include, wrapped in an async function so it runs as a file. The browser style assumes it sits inside an async context of your own.
Is my command uploaded anywhere?
No. Parsing and code generation run entirely in your browser. Commands often carry API keys and bearer tokens, and none of it is sent to a server, stored, or logged.

Related tools