Skip to content
100% Client-SideZero UploadGo net/http Output

cURL to Go net/http Converter — Client-Side & Free

Paste a cURL command and get a complete Go program: http.NewRequest with the right method constant, headers via req.Header.Set, JSON payloads marshalled from map[string]any literals, and basic auth via SetBasicAuth — generated entirely in your browser.

  • Zero upload, ever

    Parsing and code generation run in your browser — URLs, headers, and tokens never touch a server.

  • Live 100 ms conversion

    Output updates as you type or paste, with one-keystroke copy via Cmd/Ctrl + Enter.

  • gofmt-shaped output

    Tab-indented, import-grouped code that looks like it came out of gofmt.

Paste a cURL command to convert

Examples
100% Client-Side: Tokens & credentials never leave your browser.

cURL command

Paste a cURL command — idiomatic code appears here instantly, converted entirely in your browser.

Technical documentation

How cURL maps to Go's net/http

Go's standard library builds requests in three steps — construct, decorate, execute — and the generated code follows exactly that shape: http.NewRequest(method, url, body) from the -X flag and URL, req.Header.Set(...) for every header, and http.DefaultClient.Do(req) to send it. The output is a full main package you can run with go run main.go.

The import block is computed from what your command actually uses: bytes and encoding/json appear only for JSON bodies, strings only for raw string bodies, and the list stays alphabetized the way gofmt leaves it.

JSON bodies the Go way

Instead of embedding an opaque string, JSON payloads are emitted as map[string]any{...} literals — with nested objects, slices as []any{...}, true/false/null translated to true/false/nil — and marshalled through json.Marshal with the error checked. That keeps the payload editable as Go source and types it loosely, exactly like JSON unmarshalling into any.

Non-JSON bodies skip the marshal step entirely and are wrapped in strings.NewReader so form data and raw text hit the wire byte-for-byte as curl sent them.

Methods, auth, and wire fidelity

Standard verbs map to the http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete, http.MethodHead, and http.MethodOptions constants; anything exotic is passed as a plain string literal, which http.NewRequest accepts. Basic auth from -u becomes req.SetBasicAuth(user, pass), the canonical one-liner.

Query strings are preserved verbatim in the URL, repeated -d flags join with &, and --data-urlencode parts are percent-encoded during conversion. Content-Length is dropped because net/http computes it — just like curl does.

From snippet to production Go

The generated program prints the response body after checking every error — the minimal correct shape. To productionize: swap panic for your error strategy, add context via http.NewRequestWithContext, replace DefaultClient with a configured &http.Client{Timeout: ...}, and unmarshal into typed structs instead of printing.

Because the output is plain standard library, it compiles anywhere Go does — no third-party dependencies, no generated code licenses, nothing to vendor.

Frequently asked questions

Is this cURL to Go converter free?

Yes — free with no sign-up, quotas, or ads on the tool itself, and the conversion runs entirely in your browser so there is no backend cost to pass on.

Does the generated Go code need any dependencies?

No. It uses only the standard library (net/http, encoding/json, and friends), so it compiles with a bare Go toolchain and no go.mod requirements beyond the module itself.

How are JSON bodies represented in the Go output?

As map[string]any literals marshalled with json.Marshal, with JSON booleans and null mapped to Go's true, false, and nil. You can then swap the loose literal for typed structs as your code matures.

How is basic auth handled in Go?

The -u flag becomes req.SetBasicAuth(username, password), which net/http translates into the Authorization header at request time. Explicit Authorization headers from -H are passed through unchanged instead.

Why does the output use http.DefaultClient?

It keeps the snippet dependency-free and short. In production, replace it with a configured client — most importantly one with a Timeout — as noted in the generated code's documentation section.

Does the converter support custom HTTP methods?

Yes. Standard verbs use Go's http.Method* constants; anything else (PROPFIND, REPORT, and friends) is passed as a string literal, which http.NewRequest accepts directly.