Skip to main content

cURL to Fetch Converter

Paste a cURL command and get the equivalent JavaScript code instantly. Supports fetch(), TypeScript fetch, axios, and node-fetch. Handles headers, JSON body, basic auth, and cookies — runs entirely in your browser.

✓ fetch / axios / node-fetch ✓ TypeScript support ✓ Handles auth, JSON, cookies

Frequently Asked Questions

Why convert cURL to fetch?▼

cURL is the universal HTTP client for terminals, but most JavaScript/TypeScript projects use fetch() (built-in browsers, Node 18+), axios, or node-fetch. Converting lets you copy API examples from documentation, Stack Overflow, or AI assistants — which commonly use cURL — directly into your JS code without manually translating headers, methods, and body formats.

What is the difference between fetch() and axios?▼

fetch() is built into modern browsers and Node.js 18+ with no dependencies. It returns a Response object — you must call .json() or .text() manually, and non-2xx responses don't throw by default. axios is a library that auto-parses JSON, throws on non-2xx status codes, supports request/response interceptors, has built-in timeout support, and works consistently across environments. For simple use cases, fetch() is fine; for complex API clients, axios adds convenience.

How does the converter handle JSON bodies?▼

When the cURL -d flag contains a JSON string (starting with '{' or '['), or when the Content-Type header is application/json, the converter auto-detects it as JSON. For fetch/axios, it wraps the body with JSON.stringify() and preserves the object structure. For form-encoded data (application/x-www-form-urlencoded or --data-urlencode), it keeps it as a raw string.

What happens to Basic Auth (-u user:pass)?▼

The -u user:pass flag gets converted to an Authorization: Basic header with the base64-encoded credentials. In JavaScript, this is btoa('user:pass'). The converter encodes it directly and includes it in the headers object, so the output works without additional libraries.

Does the converter handle multiline cURL commands?▼

Yes. cURL commands split across multiple lines with backslash continuations (\) are normalized before parsing. You can paste the full multi-line command and it will be processed correctly.

What cURL flags are ignored?▼

Flags that don't have a direct HTTP equivalent are silently ignored: -L (follow redirects — fetch does this by default), -v (verbose), -s (silent), -k (insecure — fetch has no direct equivalent, use node-fetch with rejectUnauthorized for Node.js), -i (include headers in output), and timing flags like --max-time. If you need these behaviors, configure them separately in your HTTP client.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

OpenAPI Validator HTTP Status Code Reference API Request Builder API Response Mock Generator HTTP Status Code Reference HTTP Status Code Lookup HTTP Status Code Lookup Axios Interceptor Builder API Response Time Tester HTTP Methods Reference OpenAPI Schema Validator REST API Request Builder OpenAPI Mock Generator API Test Case Generator API Response Formatter & Analyzer HTTP API Tester HTTP Code Snippet Generator HTTP Status Code Reference HTTP Mock Response Builder JS Prototype Chain Visualizer API Mock Server Config Generator Mock Service Worker (MSW) API Mocking Guide API Response Mocker HTTP Headers Analyzer API Rate Limit Calculator HTTP Headers Inspector JavaScript Formatter & Minifier LLM Cost Calculator HTTP Cache-Control Builder HTTP Header Analyzer AI Prompt Cost Calculator HTTP/2 Server Push Headers Builder HTTP Security Headers Checker LLM Prompt Cost Calculator AI Rate Limit Calculator HTTP Cache Header Builder HTML5 Canvas API Playground Resource Hints Generator API Key Generator AI Doc Generator — Pro Tool Code Tools curl Command Builder HTTP Security Headers Generator JSON Diff Viewer JSON Diff Prettier Config Generator Regex Visualizer Regex Tester Pro Regex Tester TypeScript Playground TypeScript to JavaScript Converter Developer Utilities Rate Limiter Tester API Changelog Generator Rate Limit Calculator Biome Config Generator Webhook Tester CORS Policy Builder Haproxy Config Validator Caddy Caddyfile Generator HAR Diff Analyzer Vue Component Generator LLM Context Window Calculator Regex Flags Explainer LLM Token Counter Bundle Size Estimator JavaScript Memory Leak Detector SSL Certificate Checker Prompt Token Estimator NPM Bundle Size Estimator Jest Testing Framework Guide Pulumi Modern IaC Guide Bundle Size Impact Calculator Game Loop Calculator Bezier Curve Editor Particle System Config Generator Token Context Calculator OpenAI Function Calling Generator Token Counter & Cost Estimator AI API Rate Limit Calculator

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →