CurlCommands 1.0.1

dotnet add package CurlCommands --version 1.0.1
                    
NuGet\Install-Package CurlCommands -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CurlCommands" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CurlCommands" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CurlCommands" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CurlCommands --version 1.0.1
                    
#r "nuget: CurlCommands, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CurlCommands@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CurlCommands&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CurlCommands&version=1.0.1
                    
Install as a Cake Tool

CurlCommands

Parse and execute curl command strings at runtime via HttpClient. Zero external dependencies.

Install

dotnet add package CurlCommands

Usage

using CurlCommands;

using var httpClient = new HttpClient();

// Simple GET
var response = await httpClient.ExecuteCurlAsync("https://api.example.com/users");

// POST with JSON body
var response = await httpClient.ExecuteCurlAsync(
    "curl -X POST https://api.example.com/users " +
    "-H 'Content-Type: application/json' " +
    "-d '{\"name\":\"John\",\"email\":\"john@example.com\"}'");

// --json flag (auto Content-Type + Accept)
var response = await httpClient.ExecuteCurlAsync(
    "curl --json '{\"name\":\"John\"}' https://api.example.com/users");

// Save response to file
var response = await httpClient.ExecuteCurlAsync(
    "curl -o result.json https://api.example.com/users");

// Pre-parse and reuse
CurlCommand cmd = CurlCommand.Parse("curl -X POST https://api.example.com/users -d '{}'");
var response = await httpClient.ExecuteCurlAsync(cmd);

// Fire-and-forget (executes request, disposes response)
await httpClient.ExecuteCurlAndForgetAsync(
    "-X POST https://api.example.com/webhook -d '{\"event\":\"deploy\"}'");

The curl prefix is optional.

Supported Options

Option Description
-X, --request HTTP method (GET, POST, PUT, DELETE, etc.)
-H, --header Request header (Name: Value)
-d, --data, --data-raw Request body (implies POST)
--data-binary Binary request body
--json JSON request body (auto Content-Type + Accept)
-F, --form Multipart form field (name=value or file=@path)
-o, --output Save response body to file
-u, --user Basic auth credentials (user:password)
--oauth2-bearer Bearer token authentication
-b, --cookie Cookie header
-A, --user-agent User-Agent header
-e, --referer Referer header
-L, --location Follow redirects
-k, --insecure Skip SSL certificate validation
--compressed Accept gzip/deflate encoding
--connect-timeout Connection timeout in seconds
--max-time Maximum request time in seconds
--data-urlencode URL-encode data (name=value, implies POST)
-x, --proxy Use HTTP proxy
-G, --get Force GET; data becomes query string
-I, --head HEAD request
-T, --upload-file Upload file via PUT
--cert, --cert-type Client certificate (PEM, DER, P12)
--key, --key-type Client certificate private key
-U, --proxy-user Proxy credentials (user:password)
--http1.0, --http1.1, --http2, --http3 HTTP version

Features

  • Shell-accurate tokenizer -- handles single quotes, double quotes, backslash escaping, and line continuations
  • Implicit method detection -- -d implies POST, -F implies POST
  • Combined short flags -- -sLk expands to silent + location + insecure
  • Content-Type routing -- Content-Type headers are correctly placed on HttpContent, not on the request
  • JSON flag -- --json auto-sets Content-Type and Accept to application/json
  • Output to file -- -o/--output saves response body to disk
  • Basic and Bearer auth -- -u user:pass and --oauth2-bearer token
  • Multipart form data -- -F 'file=@/path/to/file;type=application/pdf'
  • Timeout support -- --max-time and --connect-timeout via CancellationToken
  • Insecure mode -- -k uses an internal HttpClient that skips certificate validation
  • URL encoding -- --data-urlencode automatically encodes values
  • Proxy support -- -x/--proxy routes requests through an HTTP proxy
  • Force GET -- -G moves -d data to query string parameters
  • File upload -- -T uploads files via PUT
  • Client certificates -- --cert/--key for mutual TLS
  • Proxy auth -- -U/--proxy-user for proxy credentials
  • HTTP version -- --http1.0 through --http3
  • Pre-parsed commands -- CurlCommand.Parse() for reuse and inspection

Error Handling

Parse errors throw CurlParseException with a descriptive message. HTTP errors follow standard HttpClient behavior -- use response.EnsureSuccessStatusCode() or check response.IsSuccessStatusCode.

using CurlCommands.Exceptions;

try
{
    var response = await httpClient.ExecuteCurlAsync("-X GET"); // no URL
}
catch (CurlParseException ex)
{
    Console.WriteLine(ex.Message); // "No URL found in curl command."
}

Target Frameworks

  • netstandard2.0 -- .NET Framework 4.6.1+, .NET Core 2.0+
  • net10.0 -- modern .NET

License

MIT

Product 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 is compatible.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 72 4/7/2026
1.0.0 76 4/7/2026