Curl → Code
Convert curl commands to Python, JavaScript, Go, and Rust code.
About this tool
Paste a curl command and this tool turns it into equivalent code for Python (requests), JavaScript (fetch), Go (net/http), and Rust (reqwest). It parses the URL, method, headers (-H), request body (-d / --data), basic auth (-u), and user agent (-A), then emits idiomatic code in the selected language.
Example: curl -X POST https://api.example.com/users -H "Content-Type: application/json" -d '{"name":"Alice"}' becomes a Python requests.post(...) call with headers and data, a JavaScript fetch() with method and body, a Go http.NewRequest with strings.NewReader, or a Rust reqwest::Client with a builder chain.
Switch languages with the tabs above the output. The status line confirms what was parsed (method, URL, header count, whether a body was detected).
FAQ
Which curl flags are supported? ›
URL, -X/--request, -H/--header, -d/--data/--data-raw/--data-binary, -u/--user (basic auth), and -A/--user-agent. Common flags like -L, -k, -s, -v, --compressed, and -i are recognized and ignored so they don't break parsing.
Does it handle multiline curl commands with backslash continuations? ›
Yes. Backslash-newline line continuations are stripped during tokenization, so a curl command split across several lines pastes and parses correctly.
What happens to the request body? ›
The raw body string is passed through as-is. For JSON bodies the generated code sends the string directly; if you need an object literal instead, parse and restructure it in your target language.
How is this different from the HTTP Request Builder? ›
This tool takes an existing curl command and converts it to code. The HTTP Request Builder works in the opposite direction — you fill in a form (method, URL, headers, body) and it generates a curl command and equivalent code snippets.