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.
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.
Related Products
on GumroadTypeScript Quick Reference Toolkit
5 practical reference files for TypeScript developers: cheatsheet, TS vs JS comparison, 20 utility types with real examples, tsconfig best practices template, and 15 common mistakes guide. Print it. Keep it on your desk.
Buy on Gumroad →DevToolkit Starter Kit
A ready-to-deploy developer tools website with 12 built-in tools. Astro + Preact + Tailwind. Deploy to Cloudflare Pages for free. Built-in SEO, dark mode, and ad-ready layout.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
OpenAPI Validator
Paste your OpenAPI 3.x spec (YAML or JSON) to validate structure, find missing required fields, detect duplicate paths, check for missing operationIds, and get errors and warnings with path references.
Open free tool →
HTTP Status Code Reference
Complete HTTP status code reference. Search all 1xx, 2xx, 3xx, 4xx, and 5xx codes with plain-English descriptions, real-world use cases, and when to use each in REST APIs.
Open free tool →
API Request Builder
Build and test HTTP requests visually with any method, headers, and body. Generate cURL commands instantly. Free online API testing tool with Pro unlimited access. No signup required.
Open free tool →
More Free Tools
Related Articles
curl 深度使用手冊:API 測試從入門到進階
curl 是每位開發者必備的 CLI 工具。本文涵蓋 GET/POST/PUT/DELETE 請求、認證、header 設定、檔案上傳、除錯技巧,以及 REST API 測試的完整實戰範例。
Hono.js: Build Blazing-Fast APIs for Edge and Serverless (2026 Guide)
Complete guide to Hono.js covering routing, middleware, RPC client, Cloudflare Workers, Bun, Deno, and Node.js runtimes, OpenAPI integration, and comparison with Express and Fastify for edge workloads.
Bun Shell Scripting Guide: Replace Bash Scripts with $.cmd() and Bun APIs
Learn how to replace complex bash scripts with Bun's built-in shell API. Covers $.cmd(), Bun.file(), spawn(), and practical real-world automation scripts.
Hono.js Complete Guide 2026: Build Ultra-Fast APIs for Edge and Beyond
Master Hono.js in 2026 — routing, middleware, RPC, Zod validation, edge deployment on Cloudflare/Deno/Bun, and how it compares to Express and Fastify.
TypeScript 5.5 New Features: Complete Guide for Developers 2026
Everything you need to know about TypeScript 5.5: inferred type predicates, isolated declarations, JSDoc @import tag, new Set methods, and performance improvements. With practical code examples.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$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.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →