curl to Axios converter
Updated Free mock REST & WebSocket APIs
Convert a curl command into an Axios request config — handy for React, Vue and Node.js projects that already use Axios.
POST https://mockfox.dev/api/fake/posts2 headersbody 52 chars
import axios from "axios";
const response = await axios({
method: "post",
url: "https://mockfox.dev/api/fake/posts",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_TOKEN",
},
data: {
"title": "Hello",
"body": "From curl",
"userId": 1
},
maxRedirects: 0, // curl doesn't follow redirects without -L (Node only)
});
console.log(response.status, response.data);🔒 Converted in your browser — your command, tokens and URLs are never sent anywhere.
How to convert a curl command
- Paste the command into the box (multi-line commands with
\continuations are fine) — or copy one from DevTools with Copy as cURL. - Pick the output language. The code updates as you type.
- Copy or download the code, and check any warnings about options that can't be converted.
Axios vs fetch for converted requests
- Axios serialises objects passed as
datato JSON automatically and parses JSON responses intoresponse.data. - It rejects the promise for non-2xx statuses (configurable with
validateStatus), unlike fetch. -u user:passmaps to Axios'authoption, which builds the Basic header for you.maxRedirects: 0mirrors curl without-L— it only takes effect in Node.js; browsers always follow redirects.
Need an endpoint to try your code against? Use the free fake REST API or test any HTTP status code.
Related tools
Frequently asked questions
Is my curl command sent to a server?
No. The converter runs entirely in your browser, so API keys, tokens and URLs in your command never leave your device.
Why does Axios throw on a 404?
Axios treats any status outside 200–299 as an error by default. Catch it and read error.response.status, or pass validateStatus: () => true to handle all statuses yourself.
How do I send multipart form data with Axios?
Pass a FormData object as data (the converter does this for -F). Axios sets the multipart Content-Type with the correct boundary.
Your business here? Sponsor this tool from $16/week. See placements