cURL to Axios Converter
Convert a common cURL command into an Axios request configuration for JavaScript. Parsing happens locally, the request is never executed, and credentials remain inside your current browser tab.
How to use it
- Paste a cURL request from API documentation, browser DevTools, Postman, or your terminal.
- Select Convert to Axios or press Ctrl/⌘ + Enter.
- Review the generated URL, method, headers, authentication, and request data.
- Install Axios with
npm install axios, copy the output, and test it only against an API you may access.
cURL to Axios example
This JSON request includes a method, bearer token, content type, and literal body:
curl -X POST https://api.example.com/v1/users \
-H 'Authorization: Bearer test-token' \
-H 'Content-Type: application/json' \
-d '{"name":"Ada","active":true}'
The converter produces an axios() call with a configuration object. The absolute address becomes url, the HTTP verb becomes lowercase method, headers remain an object, and valid JSON becomes the data object. Axios serializes that object when the request runs. The generated example logs response.data, which is the response payload Axios exposes after applying its response transforms.
Supported request configuration
Cryonel supports -X and --request, -H and --header, literal -d, --data, --data-raw, and --data-binary bodies, -u or --user Basic authentication, HEAD requests, and redirect following. When data exists without an explicit method, the converter selects POST to match cURL. When no content type is supplied for data, it preserves cURL’s default application/x-www-form-urlencoded content type.
Axios accepts both strings and JavaScript objects in its data field. Valid JSON with an application/json header becomes an object so the result is readable and editable. Form or unrecognized content remains a string to avoid changing the request. A cURL --user username:password option becomes Axios’s documented auth object. Bearer tokens and custom authorization schemes continue to use an Authorization header.
Axios redirects, errors, and adapters
The generated request adds maxRedirects: 21 when the cURL command uses -L. That setting is meaningful for Axios’s Node.js HTTP adapter. Browsers manage redirects themselves, so frontend code cannot reproduce every redirect detail. Axios normally rejects responses outside its accepted status range; use a deliberate validateStatus function only when the application really treats other statuses as successful.
Axios behavior depends on the active adapter. Browser requests are subject to Cross-Origin Resource Sharing, forbidden request headers, browser cookie policies, and TLS decisions made by the browser. Node.js can support additional transport options, agents, redirects, streams, and certificates. A terminal command therefore cannot always be translated into one snippet that behaves identically in both environments.
Unsupported cURL features
The converter rejects cookie files, explicit Cookie, Host, and Content-Length headers, client certificates, insecure TLS mode, multipart form uploads, file-backed bodies such as @payload.json, and URL-encoded data flags. These features either require file access, depend on a Node-only adapter, or are controlled by the browser. Reporting the limitation is safer than returning valid-looking Axios code with different security or request semantics.
Security and privacy
API commands often include keys, bearer tokens, Basic auth passwords, or private payloads. Cryonel does not upload or execute the command, but the generated JavaScript still contains those values. Replace secrets before committing the result, posting it in an issue, or sharing it with another person. In production, load credentials from an appropriate secret store or server-side environment rather than hard-coding them into frontend bundles.
Common conversion errors
- Basic auth format: include both username and password as
username:password. - GET or HEAD body: move values into URL parameters because browser HTTP clients reject these bodies.
- Unsupported option: remove transport-only cURL flags, convert the core request, then configure the relevant Axios adapter manually.
- CORS failure: update the target server’s allowed origins, methods, and headers. Client code cannot grant itself CORS permission.
Frequently Asked Questions
Does Cryonel execute the generated Axios request?
No. The command is parsed locally and converted to text. Cryonel never calls the supplied URL.
How does cURL Basic authentication map to Axios?
A cURL --user username:password value becomes Axios's auth object. Bearer tokens remain in the Authorization header.
Why can Axios fail when the original cURL succeeds?
Browser Axios requests follow CORS and forbidden-header rules that do not apply to terminal cURL. Node.js and browser Axios adapters also differ.