Developer Tools
cURL to Go Converter
Convert a curl command to idiomatic Go code in your browser. net/http, http.Get and http.Post shortcuts, and go-resty/resty client output.
The curl command is parsed locally in your browser. Tokens, headers, auth values, and request bodies never leave your device.
What gets converted
- Method and URL
- -X / --request sets the method explicitly. Without it, a body forces POST and -G forces GET with data folded into the URL.
- Headers and auth
- Every -H becomes a req.Header.Set call. -u user:pass becomes req.SetBasicAuth. -b cookies become req.AddCookie entries.
- JSON and form bodies
- -d values that parse as JSON are emitted inside a Go raw string. Form data is wrapped in a strings.NewReader with the matching Content-Type.
- Multipart uploads
- -F parts use mime/multipart with writer.CreateFormFile for files (resolved from os.Open) and WriteField for text fields. The Resty output uses SetFormData and SetFile instead.
How to use
- Paste a curl command into the input area, click Load sample, or pick a preset (GET, POST JSON, form login, basic auth, multipart upload, PUT with cookie).
- Pick an output style: net/http for the standard library with full control, net/http shortcut for http.Get and http.Post when the request fits, or Resty for the go-resty/resty/v2 fluent client.
- Read the summary card to confirm the method, URL, header count, and body type the parser detected.
- Click Copy code to grab the generated Go program. It is a runnable package main, so paste it into a .go file or the Go Playground and run it as is.
- Watch the warnings panel: ignored curl flags are listed by name, and multipart file fields call out the os.Open path you need to point at a real file.
About this tool
cURL to Go Converter parses a curl command the way a POSIX shell would and emits idiomatic Go HTTP code that compiles as a runnable main program. The parser handles single quotes, double quotes with backslash escapes, $'...' ANSI-C quoting, backslash-newline continuations, and glued short flags (-XPOST, -dvalue), so curl commands copied from a terminal, a runbook, or a browser DevTools "Copy as cURL" paste cleanly. Three output styles cover the requests Go developers actually write. The net/http output uses http.NewRequest with strings.NewReader or bytes.Buffer for the body, http.DefaultClient.Do for the call, and req.Header.Set, req.SetBasicAuth, and req.AddCookie for headers, auth, and cookies; multipart -F uploads are emitted with mime/multipart, os.Open, writer.CreateFormFile, and WriteField. The net/http shortcut output switches to http.Get, http.Post, or http.PostForm whenever the request fits one of those signatures (GET with no headers, POST with a single body), and falls back to the full net/http form when custom headers, auth, or cookies are present. The Resty output uses the go-resty/resty/v2 fluent client with req.SetHeader, req.SetBasicAuth, req.SetCookie, req.SetFormData, req.SetFile, and the matching method verb (req.Get, req.Post, req.Put, req.Delete, req.Patch). JSON bodies are detected by parsing -d / --data and emitted inside a Go raw string for readability; form-urlencoded bodies use url.Values when parseable. The -G / --get flag folds data into the URL as a query string before the call. The -k / --insecure flag becomes a tls.Config with InsecureSkipVerify so a request against a self-signed dev server matches what curl does. Common boolean flags such as -L, -s, -i, -v, --compressed, and --http2 are recognised and silently ignored because they do not affect the request itself, and unknown flags are reported as warnings rather than guessed at. The generated code includes the right package main, sorted import block (standard library first, then third-party), a runnable func main(), and resp.Body.Close defer plus io.ReadAll error handling so the output is the shape a Go reviewer would expect. Useful for backend engineers porting a curl example from API documentation into a Go service, SREs translating a debug command into a Go probe, students learning net/http from real curl commands, and anyone who has searched "curl to go" or "curl to golang" and bounced off a paywalled or stale tool. All parsing and code generation runs in the browser, so curl commands, auth tokens, and request bodies never leave your device.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
cURL to Fetch Converter
Convert curl into fetch, Node fetch, axios, or XHR JavaScript.
Open tool
DevelopercURL to Python Converter
Convert curl into Python requests, http.client, or urllib code.
Open tool
DevelopercURL to PHP Converter
Convert curl commands to native php-curl, Guzzle, or Laravel Http code with one click.
Open tool
DeveloperFetch to cURL Converter
Convert fetch() and axios calls to a copyable curl command for any shell.
Open tool
DeveloperJSON to Go Struct Converter
Generate idiomatic Go structs with json tags from any JSON value.
Open tool
DevelopercURL Command Builder
Form-driven builder that emits curl, PowerShell, HTTPie, wget, fetch, and raw HTTP/1.1.
Open tool