Instantly convert curl commands to Go code

This tool turns a curl command into Go code. (To do the reverse, check out moul/http2curl.) Currently, it knows the following options: -d/--data, -H/--header, -I/--head, -u/--user, --url, and -X/--request. It also understands JSON content types (see JSON-to-Go). If the content type is application/x-www-form-urlencoded then it will convert the data to Values (same as PostForm). Feel free to contribute on GitHub!

Example 1 · Example 2 · Example 3 · Example 4 · Example 5 · Example 6

Copy to clipboard

Note: http.DefaultClient will follow redirects by default, whereas curl does not without the --location flag. Since reusing the HTTP client is good Go practice, this tool does not attempt to configure the HTTP client for you.