HttpClientToCurl 2.0.8
dotnet add package HttpClientToCurl --version 2.0.8
NuGet\Install-Package HttpClientToCurl -Version 2.0.8
<PackageReference Include="HttpClientToCurl" Version="2.0.8" />
<PackageVersion Include="HttpClientToCurl" Version="2.0.8" />
<PackageReference Include="HttpClientToCurl" />
paket add HttpClientToCurl --version 2.0.8
#r "nuget: HttpClientToCurl, 2.0.8"
#:package HttpClientToCurl@2.0.8
#addin nuget:?package=HttpClientToCurl&version=2.0.8
#tool nuget:?package=HttpClientToCurl&version=2.0.8
๐ฅ HttpClientToCurl
Generate curl commands directly from your HttpClient or HttpRequestMessage in .NET โ perfect for debugging, logging, and sharing HTTP requests.
๐ Love HttpClientToCurl? Please support us!
If this project has made your life easier, consider buying us a coffee or sending a donation.
Every bit of support keeps us motivated, helps us add new features, fix bugs, and maintain the project โ keeping it free and awesome for everyone! โ๐
USDT (Tether โ BEP20 / Binance Smart Chain) wallet address:
0x9d03Be8B979453bE300724FD4bb3eF77517d45AE
๐ Badges
๐ Overview
HttpClientToCurl is a lightweight and powerful .NET extension library that turns your HTTP requests into curl commands.
It works with both HttpClient and HttpRequestMessage, giving you two simple ways to generate curl commands:
๐งฐ 1. Manual Mode
Generate curl commands on demand using extension methods on either HttpClient or HttpRequestMessage.
Best for:
Debugging individual requests, creating reproducible Postman calls, or sharing API examples.
๐งฉ 2. Automatic Mode
Automatically generates curl output whenever your app sends a request.
You can configure it through dependency injection:
- Global Registration โ enable for all
HttpClientinstances created viaIHttpClientFactory - Per-Client Registration โ enable only for selected clients
Best for:
Logging, monitoring, or tracing outgoing requests across the application.
๐ก Why Use HttpClientToCurl?
- ๐งช Instantly visualise and debug request payloads or headers
- ๐ค Share exact API calls with teammates or QA engineers
- โ๏ธ Simplify Postman and CLI reproduction
- ๐งฉ Lightweight, dependency-free, and easy to integrate
โ๏ธ Installation
dotnet add package HttpClientToCurl
Or visit the NuGet page here: <a href="https://www.nuget.org/packages/HttpClientToCurl" target="_blank">HttpClientToCurl</a>
๐ Documentation
For full examples, detailed usage, and advanced configuration options, please see the Wiki:
๐ Open Wiki โ More Details
๐ Quick Start
๐งฐ Manual Mode Usage Example
using System.Text;
using HttpClientToCurl;
class Program
{
static async Task Main()
{
var baseAddress = new Uri("http://localhost:1213/v1/");
var requestUri = "api/test";
using var httpClientInstance = new HttpClient { BaseAddress = baseAddress };
string requestBody = @"{""name"":""sara"",""requestId"":10001001,""amount"":20000}";
var httpRequestMessageInstance = new HttpRequestMessage(HttpMethod.Post, requestUri)
{
Content = new StringContent(requestBody, Encoding.UTF8, "application/json")
};
httpRequestMessageInstance.Headers.Add("Authorization", "Bearer YourAccessToken");
// Option 1: Generate curl from HttpClient
httpClientInstance.GenerateCurlInConsole(httpRequestMessageInstance);
// Option 2: Generate curl from HttpRequestMessage
httpRequestMessageInstance.GenerateCurlInConsole(baseAddress);
await httpClientInstance.SendAsync(httpRequestMessageInstance);
}
}
โ Example Output
curl -X POST 'http://localhost:1213/v1/api/test' \
-H 'Authorization: Bearer YourAccessToken' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"name":"sara","requestId":10001001,"amount":20000}'
๐งฉ Automatic Mode Usage Example
1๏ธโฃ Per-Client Registration
Enable curl logging for specific named clients only.
Program.cs / Startup.cs
using HttpClientToCurl;
// Register the curl generator once
builder.Services.AddHttpClientToCurl(builder.Configuration);
// Enable curl logging for selected clients
builder.Services.AddHttpClient("my-client1", showCurl: true);
appsettings.json
"HttpClientToCurl": {
"Enable": true, // Master switch: enable or disable the entire HttpClientToCURL logging system
"ShowOnConsole": {
"TurnOn": true, // Enable console output for generated curl commands
"NeedAddDefaultHeaders": true, // Include default headers (like User-Agent, Accept, etc.) in the curl output
"EnableCompression": false, // Compress the console log output (not recommended for debugging readability)
"EnableCodeBeautification": true // Beautify and format the curl command for better readability
},
"SaveToFile": {
"TurnOn": true, // Enable saving the generated curl commands into a file
"NeedAddDefaultHeaders": true, // Include default headers (like User-Agent, Accept, etc.) in the curl output
"EnableCompression": false, // Compress the saved file (useful if logging a large number of requests)
"Filename": "curl_commands", // Name of the output file without extension (e.g., will produce curl_commands.log)
"Path": "C:\\Users\\Public" // Directory path where the log file will be created
}
}
2๏ธโฃ Global Registration
Enable curl generation globally โ every HttpClient created through IHttpClientFactory will automatically log curl commands.
Program.cs / Startup.cs
using HttpClientToCurl;
// Register global curl generation
builder.Services.AddAllHttpClientToCurl(builder.Configuration);
// Register default HttpClient (now curl-enabled)
builder.Services.AddHttpClient();
appsettings.json (same configuration options as above)
๐งฉ Features
| Feature | Description |
|---|---|
| ๐ Methods | Supports GET, POST, PUT, PATCH, DELETE |
| ๐ง Content Types | JSON, XML, FormUrlEncodedContent |
| ๐พ Output | Console โข File โข String |
| ๐จ Beautified Output | Optional pretty printing |
๐ Articles
- How to Generate curl Script of the HttpClient in .NET
- New Feature in HttpClientToCurl for .NET: Debugging HttpRequestMessage Made Easy
๐ก Contribute
Found a bug or want to improve this project? Open an issue or submit a pull request.
๐ง Contact: amin.golmahalle@gmail.com
โญ Give a Star
If you find this project helpful, please give it a โญ โ it helps others discover it too!
๐ Contributors
<a href="https://github.com/amingolmahalle/HttpClientToCurlGenerator/graphs/contributors"> <img src="https://contrib.rocks/image?repo=amingolmahalle/HttpClientToCurlGenerator" /> </a>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection (>= 9.0.10)
- Microsoft.Extensions.Http (>= 9.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.10)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on HttpClientToCurl:
| Package | Downloads |
|---|---|
|
SomeGenericDev.RestSharpToCurl
A tiny and hacky library that uses reflection and DelegatingHandlers to generate a cURL script out of RestSharp's requests. |
|
|
PubSea.Framework
It is a Domain Driven Design Framework, including contracts for creating unified rest api and some helpers. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on HttpClientToCurl:
| Repository | Stars |
|---|---|
|
Reaparr/Reaparr
Plex downloader that brings content from any server to yours!
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.8 | 171 | 12/13/2025 |
| 2.0.7 | 62,338 | 8/21/2025 |
| 2.0.6 | 769,521 | 3/13/2024 |
| 2.0.5 | 39,098 | 1/19/2024 |
| 2.0.3 | 10,694 | 12/20/2023 |
| 2.0.2 | 97,207 | 10/1/2023 |
| 2.0.1 | 6,311 | 8/13/2023 |
| 2.0.0 | 20,297 | 5/25/2023 |
| 1.9.0 | 23,382 | 3/13/2023 |
| 1.8.9 | 702 | 3/1/2023 |
| 1.8.8 | 3,113 | 2/9/2023 |
| 1.8.7 | 721 | 2/7/2023 |
| 1.8.6 | 668 | 2/6/2023 |
| 1.8.5 | 705 | 1/25/2023 |
| 1.8.3 | 1,035 | 11/23/2022 |
| 1.8.2 | 749 | 10/31/2022 |
| 1.8.1 | 850 | 9/19/2022 |
| 1.8.0 | 883 | 9/19/2022 |
| 1.7.0 | 893 | 9/13/2022 |
| 1.6.0 | 815 | 9/13/2022 |
| 1.5.0 | 871 | 9/11/2022 |
| 1.4.0 | 835 | 9/10/2022 |
| 1.3.0 | 808 | 9/6/2022 |
| 1.2.0 | 822 | 9/5/2022 |
| 1.1.0 | 805 | 9/5/2022 |
| 1.0.0 | 1,443 | 9/1/2022 |
2.0.8