Convert curl to C#

Instantly convert your curl commands to C# code using the HttpClient library. Free, fast, and no signup required.

Examples:
Type or paste a curl command and click 'Convert' to see the code.
Target language:

Enter a curl command and click Convert to see the C# code

About C# HTTP Requests

C#'s HttpClient is the modern, recommended way to make HTTP requests in .NET applications. It's designed for reuse across multiple requests, supports async/await natively, and provides a clean, intuitive API. HttpClient is part of the System.Net.Http namespace and is available in .NET Core, .NET 5+, and .NET Framework.

Key Features

  • Modern async/await support
  • Connection pooling and reuse
  • Automatic content encoding/decoding
  • Built-in JSON serialization (.NET 5+)
  • Support for HTTP/2 and HTTP/3
  • Typed headers and content classes
  • IHttpClientFactory for dependency injection

View official HttpClient documentation

Frequently Asked Questions

How do I convert a curl command to C#?

Paste your curl command in the input box and click "Convert". The tool generates C# code using HttpClient with async/await patterns.

Should I create a new HttpClient for each request?

No! HttpClient is designed to be reused. In production code, use IHttpClientFactory or a singleton HttpClient to avoid socket exhaustion.

How do I parse JSON responses in C#?

Use System.Text.Json (built-in .NET 5+) or Newtonsoft.Json. Example: JsonSerializer.Deserialize<YourClass>(responseBody)

Does the code work with .NET Framework?

Yes! HttpClient is available in .NET Framework 4.5+ and all versions of .NET Core/.NET 5+. Some features may vary between versions.

How do I add timeouts to C# HTTP requests?

Set the HttpClient.Timeout property, or use CancellationTokenSource for more granular control over request cancellation.

Convert curl to Other Languages