cURL

cURL to Fetch

Convert cURL to Fetch, Python requests or Axios code

API & HTTP
🔒 100% client-side — your data never leaves this page
Maintained by Evan•Updated: October 18, 2026•Reviewed: October 18, 2026

Paste one request with single quotes, double quotes or backslash line continuations. Conversion generates code without sending the request.

Try an example

Commands stay in this page’s memory, without upload or saved drafts. Copying writes to your system clipboard.

Request code

For modern browsers or Node.js 18+. Browser CORS, cookies and restricted headers still apply; cross-origin redirects without -L may expose only status 0.

Converted code appears here. Changing the format or response type updates the result.

Supported cURL to Fetch syntax

Supports -X / --request, -H / --header, --url, -I, -G, -L and literal --data, --data-raw, --data-binary and --data-urlencode values. URL encoding uses UTF-8. Request bodies stay literal, so JSON numbers are not reparsed or rounded.

File loading, multipart uploads, shell expansion, command chains, repeated headers and unknown options produce explicit errors. GET/HEAD bodies are rejected; use -G to put data in the query string.

Auto mode parses application/json and +json responses as JSON and keeps other responses as text. Empty responses return null (None in Python). JSON mode rejects nonempty invalid JSON. For binary downloads, change the code to read a Blob or bytes.

Page reading mode

The full guide also includes pitfalls, worked examples, snippets, FAQs, and related tools for checking results or troubleshooting.

About this tool

Convert a literal cURL request to JavaScript Fetch, Python requests or Axios for Node.js. Choose automatic Content-Type detection, JSON or text response handling; empty responses return null or None. Inspect the URL, method, headers and raw body before copying. Unsupported options, file input and shell expansion stop conversion with an explanation. The tool generates code without sending requests, uploading the command or saving a draft.

Failure Clinic (Common Pitfalls)

The server returns text or no content

Cause: Calling a JSON parser on an empty response or ordinary text fails even when the HTTP request succeeds.

Fix: Use Auto for endpoints with accurate Content-Type headers, or Text for a text endpoint. Empty responses return null or None. Choose JSON only when nonempty responses are expected to contain JSON.

Production Snippets

Encode query values without changing the existing URL

text

Input:
curl 'https://api.example.com/search?sort=new#results' -G --data-urlencode 'q=hello world'

Method: GET
URL: https://api.example.com/search?sort=new&q=hello%20world#results
Body: none

Select Fetch, Python requests or Axios, then choose how to read the response.

Frequently Asked Questions

Why does conversion stop for @file, -F or an unknown option?

Those options can change the request in ways this converter does not reproduce. Files and stdin are not read, multipart uploads are unsupported, and shell expressions are not evaluated. Paste a literal body with --data or --data-raw and explicit headers. A leading @ is literal only with --data-raw.

How are empty, JSON and text responses handled?

The generated code reads the response once. Empty text returns null (None in Python), including ordinary HEAD and 204 responses. Auto mode parses application/json and +json media types; other types remain text. JSON mode reports malformed nonempty JSON. Binary responses need a Blob or byte-reading adaptation.

Will browser Fetch behave exactly like terminal cURL?

No. Browsers enforce CORS and restrict cookies and some headers. Redirect following is enabled by -L; without it, a browser cross-origin redirect may expose only status 0. Python requests and the Node.js Axios output require their respective packages. Review the target environment before running the code.

Are pasted tokens or commands saved?

Commands stay in the current page memory. They are not uploaded, executed or saved as drafts. Opening this version removes the old converter draft from local storage. Copy writes the generated code, including any credentials it contains, to the system clipboard.

Keep browsing