cURL to Fetch & Axios Converter

Paste a cURL command and check the normalized method, URL, headers and body, then copy the cURL, fetch or axios code. Anything the page cannot reproduce is reported before you copy.

Runs locally in your browser
Import cURL

Supports common -X, -H, -d, --url, -u, and -b options. It reads only the command you paste.

Normalized request
cURL
Import a cURL command or complete the request fields.
Fetch
Import a cURL command or complete the request fields.
Axios
Import a cURL command or complete the request fields.

Review generated requests before running them

Conversion preserves the method, URL, headers, and body you enter. Verify credentials, cookies, redirects, response handling, and environment-specific URLs before adding code to your application.

How to turn a cURL command into request code

Paste a cURL command and the page fills the request fields that sit above the code panels: method, URL, one header per line, and the body. The three panels then show the same request as a cURL command, as browser fetch code and as an axios call, so you can move a command you tested in a terminal into the JavaScript client you are actually writing.

Parsing, encoding and code generation run in this tab. The page does not send the request and does not call the URL: no request leaves the browser while the tool works. A pasted command often carries an Authorization header, a session cookie or an API key, so treat it as a secret — it stays in the page, but it also stays readable in the fields and in the generated code.

  1. Paste the command into the cURL box, or skip the import and type the method, URL, headers and body yourself. Long commands copied from a shell keep working: a backslash followed by a line break is joined.
  2. Press Import cURL. The normalized request appears above the panels, and the method list switches to the verb in the command, adding a new entry when the command uses a custom one such as -X PURGE.
  3. Read the status line. Options the snippet cannot carry over — multipart forms, uploads, proxies, client certificates, values read from files, headers without a colon — are listed after "Skipped:" so you know what to re-add by hand.
  4. Check the URL, headers and body, then press Generate code after any manual edit. The cURL panel is rebuilt from the fields, so an edit can never leave stale code on screen.
  5. Copy the snippet you need: Copy cURL for the shell command, or the fetch and axios panels for JavaScript, then run it in your own project.

What the importer reads, keeps and skips

Options the importer understands

The importer reads the options that shape the request: -X/--request for the method, -H/--header, -d/--data with its -raw, -binary and -ascii variants, --data-urlencode, --json, --url, -u/--user for HTTP Basic, -b/--cookie, -A/--user-agent, -e/--referer and -I/--head. Short options accept an attached value, so -XPOST and -H'Accept: text/html' work, and switches can be bundled, as in -sS or -kL. Repeated -d values are joined with & the way curl does it, and --data-urlencode percent-encodes everything outside the unreserved set, so --data-urlencode 'q=a b&c' becomes the body q=a%20b%26c.

Switches that only affect how curl runs — -o/--output, -m/--max-time, --retry, -L, -k, -s, --compressed, --http2 and friends — are accepted and ignored, because the generated code has no equivalent. Anything that would change the request in a way the snippets cannot express is reported instead of being dropped silently: -F/--form, -T/--upload-file, -G/--get, -x/--proxy, client certificates, --netrc, @file values for -d, -H and -b, a header line without a colon, and unknown options all appear in the "Skipped:" list.

How the three snippets are built

The cURL panel is assembled from the fields, not copied: one option per line with --request, --url, --header for every header and --data for the body, with single quotes around each value. The fetch panel emits fetch(url, {…}) with the method, a headers object and a body; when a Content-Type header contains "json", the body is written as JSON.stringify({…}) so the request keeps its shape, otherwise the body is emitted as a JSON string. The axios panel follows the same rules with a lowercase method, url, headers and data, so the two JavaScript snippets can be compared line by line.

The method is taken from the command, defaulting to GET and to POST when a body is present; -I sets HEAD unless an explicit -X overrides it. Duplicate header names collapse into one key in the headers object of the fetch and axios panels, while the cURL panel keeps every line. URL validation accepts what a browser can call: an absolute URL with a scheme. If the scheme is not http:// or https://, the snippets are still generated but the status line warns that only cURL will be able to run the request.

What the tool does not do

The conversion runs in one direction. A cURL command (or a request you type yourself) becomes cURL, fetch and axios code; the page cannot read fetch or axios source and turn it back into a cURL command. It also never executes the request, so nothing here tells you whether an endpoint answers, which status code it returns or whether a token is still valid.

Some parts of a command simply cannot cross into a browser snippet. curl can read a body, a header or a cookie from a file, build a multipart form, use a proxy, or present a client certificate; a page cannot reach your filesystem or your proxy settings, and a hand-written multipart body would need a boundary. Those options are listed rather than guessed at, so the generated code keeps only what is reproducible and the rest stays in your terminal. When a command uses one of them, run curl itself for that part and use this page for the parts that port cleanly.

Recent tools: