cURL to Fetch Converter
Paste a cURL command and get equivalent code in JavaScript fetch, Axios, Python requests, Go or PHP. Headers, methods, JSON bodies, form data, basic auth and cookies are all translated.
The reverse translation is the Curl Command Builder, and the related client-side translator is the Postman to Fetch Converter. To inspect what the converted request returns, the HTTP Header Checker reads the response.
How to use the cURL to Fetch
- 1 Paste your curl command.
- 2 Choose fetch or another target.
- 3 Convert. Flags become request options and headers become an object.
- 4 Check the notes for flags that have no direct equivalent.
Reproducing a request in code
A curl command is the canonical description of an HTTP request, which makes it a good interchange format. Converting it to fetch produces the same request as data, ready to be embedded in an application rather than typed in a terminal.
The gap between them is the environment. Curl is a command-line client with filesystem access and no origin restrictions. Fetch runs inside a page's security model. Recognizing which failures come from that difference rather than from a mistake in the request saves a lot of debugging.
- Method, URL and headers translate directly.
- Redirect following and cookie handling differ in the browser.
- Basic auth becomes an explicit authorization header.
- File output has no equivalent and needs rewriting.
Frequently asked questions
How do basic auth flags translate?
The credential flags produce an authorization header with a base64-encoded pair. The generated code usually emits that header explicitly rather than using a fetch option, since not all targets support the option. Be careful not to paste a real credential into a shared codebase.
Why does the converted request fail in the browser?
Because curl has none of the browser's restrictions. Cross-origin requests need the server to permit them, cookies are handled differently, and certain headers cannot be set from browser code at all. A curl command that works from a terminal may be impossible to reproduce exactly in a page.
What happens to output flags?
They have no equivalent, because fetch returns a response object rather than writing bytes somewhere. Saving to a file becomes reading the response body and handling it as a blob or text. That transformation is semantic rather than mechanical, and it has to be done deliberately.
Related Developer Tools
You might also need
Tools from other categories that people pair with the cURL to Fetch: