Advertisement

cURL to Go

Paste a cURL command and convert it into Go net/http code. Builds the request, sets headers, handles basic auth and prints the response.

cURL to Go

Paste a cURL command below.

Advertisement

How the conversion works

The parser extracts the method, URL, headers and body, then emits a complete Go program: http.NewRequest with a strings.Reader body, Header.Set calls, SetBasicAuth for -u, and a DefaultClient.Do with the response printed to stdout.

Ready to run

The output is a full package main program, not a snippet. Save it as main.go and run go run main.go to replay the request immediately, which is handy for backend debugging.

cURL to Go FAQs

Which cURL flags are supported?
-X/--request, -H/--header, -d/--data variants, -u/--user, -A/--user-agent and --url are parsed. The -k insecure flag has no direct equivalent and is left out.
How are request bodies handled?
The body becomes strings.NewReader with the exact payload. For large uploads, swap it for a file reader or bytes buffer in your own code.
Does it follow redirects?
http.DefaultClient follows up to 10 redirects automatically, matching what most cURL users expect without -L.
Is the request executed by this tool?
No. The tool only generates Go source code. Nothing runs until you compile and execute it yourself.
Is my command uploaded?
No. Parsing runs entirely in your browser, so tokens and API keys never leave your device.
Advertisement