Convert Curl to Fetch
Convert cURL to fetch/axios/node-fetch with TypeScript option. Handles auth, cookies, JSON body without double-encoding. Free, offline, client-side, instant.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Convert cURL commands to JavaScript fetch, axios, or node-fetch code. Supports basic auth, cookies, query strings (-G), multipart (-F), and serializes JSON bodies correctly (no double-stringify).
How to Use Convert Curl to Fetch
- Open Chrome DevTools → Network tab, right-click a request → Copy as cURL.
- Paste into the input pane (or click Load sample to see expected formats).
- Pick a target: browser
fetch(), fetch + TypeScript types,axios, or Node.jsnode-fetch. - Toggle async/await wrapping if you want the
await fetch()+const data = await response.json()boilerplate. - Toggle Include credentials to add
credentials: 'include'(required for cookies in cross-origin requests). - The tool handles:
-X,-H,-d/--data*,-u user:pass(basic auth → Authorization header),-b/--cookie,-A/--user-agent,-G+-d(query string),-F(multipart). - Copy or download the generated code.
Frequently Asked Questions
What’s “Copy as cURL”?
Browser DevTools feature. In Chrome/Edge: right-click a network request → Copy → “Copy as cURL” (Chrome uses bash format; pick “Copy as cURL (bash)” on Windows for Unix-style flags). Firefox: Copy → “Copy as cURL”. The output is a single-line or multi-line cURL command that exactly reproduces the request – paste it here to convert it to JS.
How does basic auth conversion work?
cURL: -u admin:secret. The tool base64-encodes admin:secret (to YWRtaW46c2VjcmV0) and adds Authorization: Basic YWRtaW46c2VjcmV0 header to the fetch options. Note: Basic auth credentials are visible to anyone with access to the encoded string – encode once, use over HTTPS only.
What about -G + -d (query strings)?
cURL: curl -G 'https://api.com/search' -d 'q=hello' -d 'limit=10' → makes a GET to https://api.com/search?q=hello&limit=10. The tool detects -G and converts the body parts to URL query string instead of POST body. The fetch URL is fully constructed; no body added.
How is multipart (-F) converted?
cURL: -F '[email protected]' -F 'name=jane'. The tool emits a self-invoking arrow function that builds a FormData object: body: (() => { const formData = new FormData(); formData.append("name", "jane"); ... return formData; })(). For @file references, it leaves a comment for you to substitute the actual File/Blob object – browsers can’t read arbitrary filesystem paths without user interaction.
fetch vs axios – which target?
fetch: built-in browser API, no dependency. Default for browser code. axios: more conveniences (auto JSON parse, interceptors, request cancellation, progress events) but adds 14 KB. Use axios when you need its features OR if the codebase already uses it. node-fetch: ports browser fetch to Node.js (Node 18+ has native fetch, so node-fetch is mainly for older Node versions).
Does it support TypeScript types?
The “fetch + TypeScript” target emits the same code with a TypeScript comment header. The tool doesn’t auto-infer response types (that would require schema knowledge). Add type assertions like const data = await response.json() as User or define interfaces inline.
What’s “Include credentials”?
credentials: 'include' tells fetch to send cookies on cross-origin requests AND to honor Set-Cookie response headers cross-origin. Required for cookie-based auth across domains. Default (without this flag) is same-origin – cookies only sent same-origin. Without the toggle, your auth cookies may not be sent to your API if it’s on a different domain.
What flags aren’t supported?
Not converted: --cert, --key, --cacert (client certs – fetch can’t load filesystem certs in browser), --proxy (browsers don’t expose proxy in fetch options), -o/--output (file output – use response.blob() + URL.createObjectURL manually), --resolve (DNS overrides). Most are browser-security-blocked anyway.
Is my data secure?
Yes. cURL input + generated code stay in your browser. The base64 encoding for basic auth is purely client-side. API keys and tokens in your cURL never leave your device.
Related Tools
Convert Curl to Php Curl →
Convert cURL to PHP curl_setopt() code. Auto-POST detection, JSON-safe parsing, basic auth, cookies, multipart.…
Convert Curl to Python Requests →
Convert cURL to Python requests/httpx/aiohttp. JSON-safe, auth, cookies, multipart. Free, offline, client-side, instant, secure.
Android AssetLinks JSON Generator - App Links →
Android AssetLinks JSON Generator files for Android App Links. Configure package names and SHA-256…
Convert ASCII to Binary →
Convert ASCII to Binary tool. Convert text to binary and binary to text. 100%…
Base32 Encoder/Decoder →
Free Base32 encoder and decoder tool. Encode or decode Base32 strings online. 100% client-side,…
Base58 Encoder/Decoder →
Free Base58 encoder and decoder tool. Encode or decode Base58 strings like Bitcoin addresses.…
Base64 Encoder and Decoder →
Base64 Encoder and Decoder - Convert text strings into Base64 format or decode Base64…
BBCode to HTML Converter →
Generate standard semantic HTML arrays translating classic forum BBCode syntax cleanly explicitly mappings independently…
Convert Binary to Hex →
Convert Binary to Hex tool. Convert binary numbers to hex instantly. 100% client-side, instant,…
Convert BSON to JSON →
Convert MongoDB BSON hex dumps to readable JSON in your browser. Free, offline, client-side…
Chmod Calculator →
Chmod Calculator - Build Linux chmod permissions visually - read/write/execute for owner, group, public,…
Coin Flip →
Free Coin Flip Online streaks, batch 10 000 flips, and optional crypto-grade RNG. Full…