DEV Community

IronSoftware
IronSoftware

Posted on

CurlDotNet: Bringing curl's Power to .NET

CurlDotNet: Bringing curl’s Power to .NET 10

Sponsored by IronSoftware.com

By Jacob Mellor


A Problem Every .NET Developer Knows

If you work with HTTP APIs—even occasionally—you’ve seen the same pattern: API documentation shows curl commands. Blog posts show curl commands. Support engineers send you curl commands. curl is the closest thing our industry has to a universal dialect for “here’s how you call our API.”

But .NET developers immediately hit a wall:

you can’t paste curl into C#. You must translate it into HttpClient code.

And that translation looks deceptively simple… until it isn't.

Headers get missed. Data gets encoded incorrectly. Authentication behaves differently.

You lose time, introduce subtle bugs, and break your flow.

What if you could skip that entire translation step?


Introducing CurlDotNet

CurlDotNet lets you paste curl commands directly into your .NET code.

No shell calls. No external executables. No rewriting.

It is a pure .NET library that understands curl syntax and executes it natively.

The Core Idea

Paste the same curl you see in documentation, and CurlDotNet turns it into a real .NET HTTP request:

var result = await Curl.ExecuteAsync(@"
  curl https://api.stripe.com/v1/charges     -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:     -d amount=2000     -d currency=usd     -d source=tok_mastercard     -d description='My First Test Charge'
");

if (result.IsSuccess)
{
    var charge = result.ParseJson<StripeCharge>();
    Console.WriteLine($"Payment successful! ID: {charge.Id}");
}
Enter fullscreen mode Exit fullscreen mode

That’s it.

No manual translation.

No fiddling with HttpRequestMessage.

No surprise bugs from missing flags.


Why CurlDotNet Matters

1. It Removes Translation Errors

Senior developers know the pain: you copy a curl command and start rewriting it in a typed language.

Beginners struggle because curl uses short flags and cryptic switches, and it’s not obvious how they map to C#.

CurlDotNet solves both problems: the curl string is the request.

2. It Matches The Real World

Every major API provider uses curl in their documentation:

  • Stripe
  • GitHub
  • Twilio
  • AWS
  • DigitalOcean
  • Cloudflare

CurlDotNet lets you use those examples exactly as they were written.

3. Perfect for Rapid Exploration

When you’re prototyping or testing an API, you don’t want boilerplate—you want results.

Paste. Execute. Inspect.

4. Ideal for Migrating Legacy Scripts

If your team has old bash automation scripts full of curl commands, CurlDotNet lets you port them directly into production-ready C#.


Key Features

Full curl Compatibility

CurlDotNet supports the entire curl option set, including:

  • All HTTP verbs
  • Custom headers
  • Form fields and JSON requests
  • File uploads
  • Authentication (Basic, Bearer, token-based)
  • Redirect handling
  • SSL/TLS options
  • Proxies
  • Cookies
  • Timeouts and retry behaviour

If curl can express it, CurlDotNet can run it.


Two Ways to Use CurlDotNet

1. Paste curl Directly

This is the headline feature:

var result = await Curl.ExecuteAsync(
    "curl -X POST https://api.example.com/data -H 'Content-Type: application/json' -d '{"key":"value"}'"
);
Enter fullscreen mode Exit fullscreen mode

2. Fluent Builder API

When you want IDE hints, type safety, or dynamic request building:

var result = await CurlRequestBuilder
    .Post("https://api.example.com/data")
    .WithHeader("Content-Type", "application/json")
    .WithJson(new { key = "value" })
    .WithTimeout(TimeSpan.FromSeconds(30))
    .FollowRedirects()
    .ExecuteAsync();
Enter fullscreen mode Exit fullscreen mode

Both approaches use the same execution engine.


Developer Experience Highlights

  • Rich response model including status code, headers, body text, binary data, timing info.
  • Intuitive JSON helpers like ParseJson<T>().
  • Streaming responses for large downloads.
  • Comprehensive exception hierarchy mapping curl error codes to .NET exceptions.
  • Works across Windows, Linux, macOS without external dependencies.

This is a library designed to reduce cognitive load, not add to it.


Real-World Examples

1. API Integration Made Simple

var result = await Curl.ExecuteAsync(@"
  curl https://api.github.com/user     -H 'Accept: application/vnd.github.v3+json'     -H 'Authorization: token YOUR_TOKEN'
");

var user = result.ParseJson<GitHubUser>();
Console.WriteLine($"Logged in as {user.Login}");
Enter fullscreen mode Exit fullscreen mode

2. Replacing Bash in CI Pipelines

var deploy = await Curl.ExecuteAsync(@"
  curl -X POST https://api.example.com/deploy     -H 'Authorization: Bearer $DEPLOY_TOKEN'     -d '{""env"":""prod""}'
");
Enter fullscreen mode Exit fullscreen mode

3. File Downloads

var download = await Curl.ExecuteAsync(
    "curl -o report.pdf https://example.com/reports/2024.pdf"
);

Console.WriteLine($"Downloaded {download.BinaryData.Length} bytes");
Enter fullscreen mode Exit fullscreen mode

Technical Excellence

Pure .NET

No shell execution.

No external curl installation.

No P/Invoke.

Performance

  • Async from end to end
  • Stream-based transfers
  • Minimal allocations
  • Efficient parsing engine

Compatibility

  • .NET 8
  • .NET Standard 2.0
  • .NET Framework 4.7.2+

If your app runs on .NET, CurlDotNet runs with it.


Why IronSoftware Sponsors CurlDotNet

IronSoftware builds developer tools that remove friction:

  • IronPDF
  • IronOCR
  • IronXL
  • IronBarcode

CurlDotNet fits the same mission:

give developers tools that save time, cut errors, and streamline work.


Get Started

Install via NuGet:

dotnet add package CurlDotNet
Enter fullscreen mode Exit fullscreen mode

Use it:

using CurlDotNet;

var result = await Curl.ExecuteAsync(
    "curl https://api.github.com/users/octocat"
);

Console.WriteLine(result.Body);
Enter fullscreen mode Exit fullscreen mode

You’re done.


The Bigger Vision

curl is already the lingua franca of HTTP requests.

CurlDotNet brings that power directly into .NET with zero translation overhead.

The goal is simple:

let developers stay focused on solving problems—not rewriting boilerplate.


Community & Links


IronSoftware — making developer tools for real-world engineering.

Learn more at: https://ironsoftware.com

Top comments (0)