curl to Go Converter

Convert a curl command to Go net/http code instantly in your browser. The command stays on your device.

Your curl command is converted to Go locally in your browser and never uploaded, but avoid pasting real production tokens or credentials into any tool.

Need a JavaScript version too? Try cURL to Fetch.

About cURL to Go

This curl to go converter rewrites a curl command as idiomatic Go using the standard net/http package, so you can drop an API call straight into a Go service without wiring it up by hand. As a curl to golang tool it reads flags like -X, -H, -d, --data-raw, --json, -u, -b, and -G, builds an http.NewRequest with the right method, sets each header with req.Header.Set, and wraps the body in a strings.NewReader. The generated main() reads the response with io.ReadAll and prints the status, ready to compile with go run. Use it when porting a curl test into a backend handler, a CLI, or a worker. The conversion happens in your browser, so the command and any tokens in it are processed locally on your device and never leave it.

Features

How to use the cURL to Go

  1. Paste your curl command into the cURL command box.
  2. Read the generated Go net/http program in the output panel.
  3. Check the warning banner for any flags that were adjusted or skipped.
  4. Click Copy, or download the file as request.go and run it with go run.

Example

Input

curl https://api.example.com/ping

Output

package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    url := "https://api.example.com/ping"
    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        panic(err)
    }

    res, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer res.Body.Close()

    data, _ := io.ReadAll(res.Body)
    fmt.Println(res.Status)
    fmt.Println(string(data))
}

A bodyless GET passes nil to http.NewRequest and skips the strings import.

Common errors & troubleshooting

Frequently asked questions

How do I convert a curl command to Go?
Paste the curl command into the input box and the converter renders a complete Go net/http program on the right that you can copy or download as request.go.
Does the generated Go code use the standard library?
Yes. It uses net/http, io, fmt, and strings from the standard library only, so there is nothing extra to go get before running it.
How is the request body represented in Go?
The body is wrapped in strings.NewReader and passed to http.NewRequest, and the strings import is added automatically only when a body is present.
Can I run the output directly with go run?
Yes. The converter emits a full package main with a main() function, basic error handling, and response printing, so go run request.go works as-is.
Is my curl command sent to a server when I convert it to Go?
No. The curl to go conversion runs entirely in your browser, so the command and any secrets in it stay on your device.

Related tools

All ArrayKit tools