curl to C# HttpClient

Paste a curl command, get clean .NET 8 HttpClient code, plain or as a typed client.

Runs locally · nothing uploaded
curl command
C#
Parsed request
Notes

What it does

Paste a curl command and get C# that sends the same request with HttpClient. It understands what DevTools and Postman actually produce: “Copy as cURL (bash)” with $'...' strings, “Copy as cURL (cmd)” with ^ escapes, Postman’s --location / --data-urlencode, line continuations with \, ^ or a backtick, and combined flags like -sSLk.

Notable features

  • Two styles: a plain HttpClient with a reusable SocketsHttpHandler, or a typed client class registered with AddHttpClient<T>() for IHttpClientFactory, with BaseAddress, timeouts and handler settings in the registration.
  • The right content type: JSON bodies become JsonContent.Create(...) with an anonymous object (or a raw string literal if you prefer exact bytes), form data becomes FormUrlEncodedContent, -F becomes MultipartFormDataContent with file parts. A raw multipart body copied from DevTools is split back into parts.
  • Auth done properly: -u, --oauth2-bearer and Authorization headers use AuthenticationHeaderValue; --digest / --ntlm use NetworkCredential.
  • Headers HttpClient manages itself are skipped with a note: Host, Content-Length, Connection, and Accept-Encoding (replaced by automatic decompression). Browser-only sec-ch-* / sec-fetch-* headers can be dropped.
  • Notes explain anything that needs your attention: -k, credentials in code, JSON sent without a Content-Type, shell variables, ignored options.

How to use it

Paste the command, pick HttpClient or Typed client, then copy or download the .cs file. The parsed-request table shows exactly how the command was understood. Click Example to cycle through a Chrome, Postman, Windows cmd and file-upload sample.

Privacy

Everything runs in your browser; nothing is sent anywhere. The last command is kept in local storage only when it contains no credentials (tokens, cookies, passwords).