Home cURL to code
cURL to code
Paste a curl command and get fetch, axios, requests, or net/http. Headers, JSON, and basic auth stay in the request.
Why this exists
A curl sample in an API doc is easy to retype badly. A header or a JSON field goes missing, and the request fails for a reason that is hard to see.
Keeping the URL, method, headers, JSON body, and basic auth in the language you actually ship lets you paste the request and edit it.
-
01How to use it
Paste a command that starts with curl, or press Example. Changing the language rewrites the code.
An unclosed quote or a missing URL is explained above the result.
-
02What you get
The example creates a user with POST. The content type, bearer token, and JSON body land in each language.
Any option the code does not carry is listed above it.
EnteredCreate a user
Method POST URL https://api.example.com/v1/users Body JSON -
03Worth knowing
Flags that only change how curl runs, such as -L, -s, and -k, stay out of the request. Retries, proxies, and file uploads do too.
Split a command larger than 5MB. Read the URL and the token in the generated code before you commit it.
Questions
- QDoes the command leave this browser?
- ANo. Conversion stays on the page, and the curl text is not stored.
- QWhich languages are generated?
- AJavaScript fetch, axios, Python requests, Node.js 18 fetch, and Go net/http.
- QWhat happens to basic auth?
- APython gets an auth tuple. Fetch, axios, Node, and Go get an Authorization: Basic header.
- QCan a form upload become code?
- A-F and -T are not turned into a body. They are listed as options the code skips.
How this page works it out
A curl command pasted on this page is rewritten as JavaScript fetch, axios, Python requests, Node.js 18+ fetch, and Go net/http.
Basic authentication becomes the requests auth tuple in Python and a Basic authorization header in the fetch forms.
Multipart -F, output -o, upload -T, and similar flags are not turned into a request. The page ignores those flags and names each one. A command that is not curl is an error, and every quote must close.
The pasted command is converted only in this browser. It is not sent away to be rewritten.