Axios Code Generator
About this tool
About Axios Code Generator
Build an Axios request without looking up the config shape again. Fill in the method and URL, add query parameters and headers as rows, choose Basic auth (which becomes Axios's auth option) or a Bearer token, and pick a body. JSON bodies are written as plain objects in data, so Axios serialises them and sets the header itself; URL-encoded forms are sent as an encoded string with the right Content-Type; multipart uses FormData with files read through openAsBlob in Node.js, leaving the boundary to the library. Options that differ from Axios's defaults are written out with a comment, such as maxRedirects: 0 when you haven't ticked Follow redirects, or an https.Agent with rejectUnauthorized: false when you skip TLS checks for local testing. The output uses axios.request with async/await and logs the status and data. Switch tabs to get the same request as cURL, fetch, HTTPie, Python, Go or PHP. Nothing is sent from this page.
Built and maintained by Abhi JainUpdated
How to Generate Axios Code
- 1
Describe the request
Set the Method and URL and add Query parameters and Headers.
- 2
Add auth and body
Choose Basic or Bearer authorization and a Body type.
- 3
Copy
Copy the Axios code or download it as a file.
Axios Code Generator: questions and answers
How do I send a POST request with Axios?
await axios.post(url, data, { headers }) or axios.request({ method: 'post', url, data, headers }). An object in data is sent as JSON automatically.
How do I set headers in Axios?
Pass a headers object in the request config, for example headers: { Authorization: 'Bearer TOKEN' }.
How do I do basic auth with Axios?
Use auth: { username, password } in the config; Axios builds the Authorization: Basic header for you.
Does Axios follow redirects?
In Node.js it follows up to 21 redirects by default; set maxRedirects: 0 to stop. In browsers redirects are handled by the browser and can't be turned off.
More HTTP Request Code Generator presets
Related tools
- cURL ConverterTurn a cURL command into fetch, Axios, Python, Go, PHP, Node or HTTPie code.
- Query String BuilderTurn key/value rows into an encoded query string and back again.
- HTTP Headers ReferenceSearchable reference of HTTP request and response headers with examples.
- JSON FormatterBeautify, minify and validate JSON with exact error locations, without changing a single value.