cURL to C# HttpClient Converter — Online & Zero-Upload
Paste a cURL command and get clean C# for .NET 6+: top-level statements, an HttpRequestMessage with the right HttpMethod, headers via request.Headers.Add, and JSON bodies in C# 11 raw string literals — converted 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.
Modern C# output
Top-level statements, raw strings, and async/await — .NET 6+ by default.
Paste a cURL command to convert
cURL command
Paste a cURL command — idiomatic code appears here instantly, converted entirely in your browser.
Technical documentation
How cURL maps to HttpClient
HttpClient sends HttpRequestMessage instances, and the converter mirrors that shape: one var request = new HttpRequestMessage(method, url) line, a request.Headers.Add(...) call per -H flag, and content attached with new StringContent(...). The method argument uses the HttpMethod.Get/Post/Put/Patch/Delete/Head/Options members, falling back to new HttpMethod("VERB") for custom verbs.
The response is consumed with await client.SendAsync(request) and ReadAsStringAsync, wrapped in using declarations so the snippet compiles clean under the latest analyzers.
Raw string literals keep JSON honest
Instead of escaping a JSON payload into a regular C# string — where every quote doubles and every typo hurts — the body is embedded in a C# 11 raw string literal ("""..."""). The JSON appears exactly as it travels over the wire, ready to inspect and edit. If a payload ever contains the triple-quote delimiter itself, the converter falls back to a fully escaped classic string.
The media type argument of StringContent receives your Content-Type header automatically, so the Content-Type header is not duplicated across both content and headers — matching how HttpClient actually applies content headers.
Auth, headers, and content headers
Basic auth from -u is base64-encoded at conversion time and emitted as request.Headers.Authorization = new AuthenticationHeaderValue("Basic", ...) — no runtime encoding code. Bearer tokens from -H pass through untouched, and when an explicit Authorization header exists, the precomputed header is skipped to avoid sending two.
Note the split the converter handles for you: content headers like Content-Type belong to the StringContent, while request headers (Authorization, X-*, Accept) go on request.Headers — misplacing them is the number-one HttpClient beginner bug.
Running and evolving the snippet
The output targets .NET 6+ (C# 10 syntax) with raw strings requiring C# 11 / .NET 7 — drop it into Program.cs of a console project and run with dotnet run. For older language versions, replace the raw string with a regular escaped string; everything else is C# 8-compatible.
In production code, prefer IHttpClientFactory registration over new HttpClient() to avoid socket exhaustion, and extend with Polly for retries — the request-building lines transfer unchanged.
Frequently asked questions
Is the cURL to C# conversion really private?
Yes. The page is static and the transpiler runs in your browser — commands with bearer tokens or basic-auth credentials are never uploaded, logged, or stored anywhere.
Which .NET version does the generated C# require?
The snippet uses top-level statements (.NET 6+) and C# 11 raw string literals (.NET 7+). On older toolchains, swap the raw string for an escaped string and the rest compiles as-is.
How is basic auth converted for C#?
-u credentials are base64-encoded during conversion and emitted as an AuthorizationHeaderValue on request.Headers.Authorization — matching curl's wire format with zero runtime encoding logic.
Why is Content-Type on StringContent instead of the headers?
HttpClient treats Content-Type as a content header, not a request header — assigning it to request.Headers throws. The converter routes it to the StringContent media type automatically.
Can I use the output with RestSharp or Refit instead?
The generated code targets the built-in HttpClient, which underpins both libraries — the URL, headers, and body mapping transfer directly if you adapt the syntax yourself.
Does the converter handle custom HTTP methods?
Yes. Standard verbs map to HttpMethod members; anything else is emitted as new HttpMethod("VERB"), which HttpClient sends verbatim.