cURL to fetch / axios Converter

Paste any curl command and instantly get equivalent JavaScript fetch() or axios code. Supports headers, JSON body, POST/PUT/DELETE, Bearer auth, and multi-line commands.

cURL Command

Tip: Press Ctrl+Enter to convert. Supports multi-line curl with backslash continuation.

About cURL to fetch / axios Converter

cURL is the universal tool for testing HTTP requests from the terminal, but copying commands into JavaScript requires manually translating every flag. This tool parses your curl command and generates equivalent fetch() or axios code instantly — preserving headers, request body, HTTP method, and auth.

How It Works

  1. Copy a curl command from your terminal, browser DevTools, or API docs
  2. Paste it into the input field
  3. Click Convert or press Ctrl+Enter
  4. Toggle between fetch and axios tabs to see both outputs
  5. Copy the code or download as a .js file

Key Features

  • Converts any curl command to fetch() or axios
  • Handles -H headers, -d / --data body, -X method flags
  • Detects JSON body from Content-Type and --json flag
  • Supports -u basic auth with automatic Base64 encoding
  • Handles multi-line curl commands with backslash continuation
  • Toggle between fetch and axios output with one click
  • Download result as a ready-to-use .js file

Frequently Asked Questions

How do I convert a curl command to JavaScript fetch?
Paste your curl command into the input field and click Convert. The tool parses all curl flags (-X, -H, -d, --json, -u) and produces an equivalent fetch() call with async/await syntax. Headers, request body, and HTTP method are all preserved exactly.
What is the difference between fetch and axios?
fetch() is built into modern browsers and Node.js 18+ with no dependencies. axios is a third-party library that adds automatic JSON serialization, better error handling (throws on 4xx/5xx), request/response interceptors, and easier timeout configuration. fetch is fine for simple use cases; axios shines in larger apps with complex request handling.
How do I add headers in fetch from a curl command?
Every -H flag in your curl command maps to an entry in the fetch headers object. For example, -H 'Authorization: Bearer token' becomes headers: { 'Authorization': 'Bearer token' } in fetch and is placed in the headers config of axios. This tool handles multiple -H flags automatically.
Can I convert a curl POST request with a JSON body to axios?
Yes — paste the full curl command including -d '{...}' and the Content-Type: application/json header, then select the axios tab. The tool detects the JSON body automatically and outputs a clean axios.post(url, body, config) call where the body is passed as a parsed JavaScript object (axios serializes it automatically).

Learn more: Developer Tools Guide