Code converters

cURL to Axios Converter

Turn a cURL command into a ready-to-run Axios request, with the query split into params and every curl option mapped to its config key.

  • Free foreverNo trial, no paywall, no usage limits.
  • No sign-upOpen the page and start. We never ask for an email to use a tool.
  • PrivateEverything runs in your browser. Your input is never uploaded or stored on our servers.
  • Works offlineOnce the page has loaded, the tool keeps working without a connection.
InputAuto-detects Bash (Copy as cURL (bash), API docs), Windows cmd (Copy as cURL (cmd), with ^ escapes) and PowerShell (backtick line breaks). Pick one if the guess is wrong.
Top-level await: reads top to bottom. Works in ES modules, Deno, Bun and the browser console.A promise chain with .then() and .catch(), for code that can't use await.
Moves the query string into a params object, which is easier to edit. Off keeps the URL exactly as pasted. Repeated keys always stay in the URL.
curl follows redirects only with -L. On: without -L the code stops at a 3xx response, exactly like curl. Off: keep the library's default.
Leaves out headers a browser adds by itself (sec-ch-ua, sec-fetch-*, priority…). They are noise when you replay a DevTools request from code.

cURL command

Paste a command from DevTools (Copy as cURL), API docs or your terminal. You can also drop a .sh or .txt file here.
Clear

JavaScript · Axios

Runnable JavaScript that sends the same request. Lines marked in amber contain credentials.
Wrap long linesCopyDownload request.js
Your JavaScript code appears here as you type.
Nothing leaves your browser.
Paste a command or load an example. It converts as you type, and nothing leaves your browser.

Parsed request

What curl would send, decoded: method, URL, query, headers, cookies and body.

Paste a command to see its method, URL, query parameters, headers, cookies and body, decoded.

Need this built into your own API or pipeline? Talk to our team

Quick answer

To convert cURL to Axios, build a request config: -X sets method, each -H goes into headers, the query string becomes params, -d or --json becomes data, -u becomes auth and -m becomes timeout in milliseconds. Paste a cURL command into Playxoft's free cURL to Axios converter and it writes the axios() call with async/await or .then(), adding maxRedirects: 0 when the command has no -L, just like curl.

  • Query to params
  • maxRedirects like curl
  • JSON, form and multipart data
  • Basic auth and proxies
  • Credential warnings
  • async/await or .then()

How to use the cURL to Axios Converter

  1. 1Paste a command into cURL command, or choose one from Load example.
  2. 2Choose async/await or .then(), and leave Query as params on to get an editable params object.
  3. 3Keep Match curl redirects on to add maxRedirects: 0 for commands without -L, or turn it off to use Axios's default.
  4. 4Review Parsed request and the notes for anything Axios can't do in a browser, such as -k.
  5. 5Run npm install axios, then copy the code or download request.js.

cURL flags cheat sheet: what does each option become in Axios?

cURLAxios config
-X PATCHmethod: "patch"
-H "Name: value"headers: { Name: "value" }
?a=1&b=2 in the URLparams: { a: "1", b: "2" }
--json '{…}' or a JSON -ddata: { … } (Axios serializes objects to JSON)
-d "a=1&b=2"data: new URLSearchParams({ a: "1", b: "2" })
-F name=@filedata: form, a FormData
-u user:passauth: { username, password }
-m 30timeout: 30000
No -LmaxRedirects: 0
-L --max-redirs 5maxRedirects: 5
-x http://host:8080proxy: { protocol, host, port }
-khttpsAgent: new https.Agent({ rejectUnauthorized: false })

Axios sets Content-Type: application/json for plain objects and application/x-www-form-urlencoded for URLSearchParams, so the converter doesn't repeat those headers. A Content-Type you set yourself with -H is always kept.

Why does the converted Axios code set maxRedirects: 0?

Because curl doesn't follow redirects unless you pass -L, and Axios does: in Node.js it follows up to 21 of them by default. A command without -L that hits a 301 or 302 shows you the redirect in curl but the final page in Axios, a quiet difference that wastes time when you're debugging an API.

With Match curl redirects on, commands without -L get maxRedirects: 0 so the code behaves exactly like curl. Two things to know:

  • Axios then rejects the 3xx response, because its default validateStatus only accepts 2xx. Read error.response.headers.location to see where it pointed, or pass validateStatus: (status) => status < 400.
  • maxRedirects only applies in Node.js. In browsers, XMLHttpRequest always follows redirects and the option is ignored.

Axios vs fetch: when is Axios the better choice?

Axios earns its place when many requests share the same behavior:

  • One client for everything. axios.create({ baseURL, headers, timeout }) gives you shared defaults, and interceptors can refresh tokens or log every call in one place.
  • Errors you can't ignore. Any non-2xx status rejects, so a failed call can't slip through as a success.
  • Progress events. onUploadProgress and onDownloadProgress drive progress bars, in the browser and (since Axios 1.x) in Node.js.

The costs: a dependency in every bundle, and params serializes arrays as ids[]=1&ids[]=2 by default. That is why the converter keeps repeated query keys such as ?id=1&id=2 in the URL instead of moving them to params. For zero-dependency code, use the cURL to fetch converter.

How do I share one Axios instance with interceptors?

A converted command is a single call. In an app, the parts every call shares (base URL, auth header, timeout) belong in one instance:

import axios from "axios";

export const api = axios.create({
  baseURL: "https://api.example.com/v1",
  timeout: 30000,
});

api.interceptors.request.use((config) => {
  config.headers.Authorization = `Bearer ${getToken()}`;
  return config;
});

api.interceptors.response.use(
  (response) => response,
  (error) => {
    if (error.response?.status === 401) signOut();
    return Promise.reject(error);
  },
);

getToken() and signOut() stand for your own helpers. The converted call then shrinks to api.get("/orders", { params: { status: "shipped" } }), and the token never has to appear in source code, unlike the one in a copied command.

Copying requests from a browser? See how to copy as cURL in Chrome or Firefox DevTools, and turn on Drop browser headers to keep sec-ch-ua, sec-fetch-mode and priority out of the Axios config.

What should I check before sharing Axios code with tokens or -k?

The converter runs entirely in your browser and never sends or stores your command. The generated code is another matter:

  • Credentials. The Contains credentials badge lists tokens, cookies and passwords found in the request, and their lines are marked in amber. Read them from the environment instead: $API_TOKEN in the command becomes process.env.API_TOKEN.
  • Basic auth. auth: { username, password } is only base64-encoded on the wire, so use it over HTTPS.
  • Certificate checks. An httpsAgent with rejectUnauthorized: false accepts any certificate, including a forged one. Use it against a local test server, never in shipped code.

Frequently asked questions

For a URL-encoded form like curl -d "a=1&b=2", pass a URLSearchParams object as data and Axios sets the application/x-www-form-urlencoded header. For multipart forms with files (curl -F), build a FormData, append fields and Blobs, and pass it as data so Axios adds the multipart boundary.
Add timeout in milliseconds to the config, for example timeout: 30000 for curl -m 30. If the server takes longer to respond, Axios rejects with an ECONNABORTED error. For a hard limit on the whole request you can also pass signal: AbortSignal.timeout(30000).
In Node.js, pass httpsAgent: new https.Agent({ rejectUnauthorized: false }), which is what the converter generates for -k. Browsers never allow skipping certificate checks. Use it only for local testing, because it also accepts forged certificates.
In Node.js, yes: up to 21 by default. Set maxRedirects: 0 to stop at the first 3xx response like curl without -L, or a number to match curl --max-redirs. In browsers redirects are always followed and maxRedirects has no effect.
Pass auth: { username: "user", password: "pass" } in the config, the equivalent of curl -u user:pass. Axios builds the Authorization: Basic header for you. For a bearer token, set the Authorization header yourself instead.
No. The converter parses the command and writes the Axios code in your browser. Nothing is sent to a server or saved, and reloading the page clears the editor.

Last updated by the Playxoft engineering team.

From the engineers who built this tool

Fighting messy data every day?

When payloads, schemas and integrations keep breaking, the fix is usually upstream. We design typed APIs and backends that stay clean as you grow. Tell us what you are building and we will suggest the simplest architecture that fits.

More free tools

See all tools

SQL Formatter

Beautify or minify SQL in 12 dialects, with keyword case, indent and line:column errors.

Open tool

cURL to Python Converter

New

Convert cURL commands into Python requests or httpx code with params, json, files and auth.

Open tool

cURL to Fetch Converter

New

Turn any cURL command into JavaScript fetch() code with headers, JSON, forms and auth.

Open tool

SQL to Prisma Converter

Turn SQL DDL into a schema.prisma with native types, relations and enums.

Open tool

SQL to Drizzle Converter

Turn SQL DDL into a typed Drizzle schema.ts with indexes, enums and relations().

Open tool

SVG to JSX Converter

Turn SVG markup or files into clean React and React Native components.

Open tool