USING IRON SUITE

Curl DotNet: Bringing Curl Superpowers to the .NET Runtime

For every .NET developer, the scenario is all too familiar: You are reading documentation for a new API, and the provider gives you a curl command to test an endpoint. You stare at the command line tool syntax, sigh, and begin the tedious process of translating it into a new HttpClient instance in C#.

You have to manually map headers, ensure the string value for the body is encoded correctly, handle the user agent, and hope you didn't miss a silent default. This manual bash copy and translation process is prone to error. One missing header, and your HTTP request fails.

Enter CurlDotNet. Created by Jacob Mellor, the CTO of Iron Software, this .NET library changes the workflow entirely. It allows you to paste curl commands directly into your code and execute them with the same behavior you expect from the terminal.

What is Curl DotNet?

CurlDotNet is a pure .NET implementation of the curl CLI tool. Unlike other wrappers, this library has no native dependencies (like libcurl.dll). It is built entirely in managed code, meaning it runs seamlessly on Windows, Linux, and macOS without complex setup.

Whether you are working on a web app in Net Core, a console application, or CI pipelines, CurlDotNet brings true curl semantics to the .NET runtime.

Key Features

  • Zero Translation: Paste curl HTTPS commands directly into your C# source.

  • Cross-Platform: Full support for Windows, Linux, MacOS, and more.

  • Type Safety: Option to use a fluent builder for dependency injection scenarios.

  • Observability: Built-in support to emit structured events for logging.

Getting Started: Install and Run

To begin, you need to install the package curldotnet via your package manager. You can find the latest version in the release notes or simply run:

dotnet add package CurlDotNet

Once installed, you can execute a curl call immediately.

The String API: Paste and Go Curl Commands

This method is perfect for health checks, support agents, or rapid prototyping. You simply pass the curl command as a string.

using CurlDotNet;

// Simply paste the command string
var response = await Curl.ExecuteAsync("curl https://api.github.com/users/octocat");

// Access the data
Console.WriteLine(response.Body);
using CurlDotNet;

// Simply paste the command string
var response = await Curl.ExecuteAsync("curl https://api.github.com/users/octocat");

// Access the data
Console.WriteLine(response.Body);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Using the Fluent Builder with Environment Variables

For production applications where you need to handle sensitive data via environment variables, or require cleaner architecture, the fluent builder is ideal. You can specify a string name for headers or set a file path explicitly.

var response = await Curl.GetAsync("https://api.example.com/data")
    .WithHeader("Authorization", "Bearer " + Environment.GetEnvironmentVariable("API_KEY"))
    .WithTimeout(TimeSpan.FromSeconds(30))
    .ExecuteAsync();
var response = await Curl.GetAsync("https://api.example.com/data")
    .WithHeader("Authorization", "Bearer " + Environment.GetEnvironmentVariable("API_KEY"))
    .WithTimeout(TimeSpan.FromSeconds(30))
    .ExecuteAsync();
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

The Iron Software Connection: Real-World Integrations

CurlDotNet is sponsored by Iron Software, a company dedicated to building tools that solve the hardest problems for developers. Jacob Mellor created CurlDotNet with the same philosophy that powers the Iron Software suite: developer experience comes first.

The true power of CurlDotNet is unlocked when combined with Iron Software products. You can use Curl for the complex transport layer (handling proxies, legacy auth, or specific curl http quirks) and Iron libraries for the heavy lifting of document processing.

Example 1: Secure PDF Download and Editing with IronPDF

IronPDF

IronPDF is the industry standard for generating pixel-perfect PDFs in .NET. Unlike other libraries that struggle with modern web standards, IronPDF renders HTML, CSS, and JavaScript exactly as a Chrome browser would. It is built to be a complete solution: you can generate new documents from HTML strings or files, edit existing PDFs, merge documents, and apply security features like watermarking and encryption without needing external dependencies or Adobe Acrobat installed on the server.

Imagine you need to download a generated invoice from a legacy internal system that requires complex curl flags (like ignoring SSL errors or specific header permutations), and then watermark it using IronPDF.

Translating that request to HttpClient might take hours of debugging. With CurlDotNet, you paste the command, get the bytes, and hand them to IronPDF.

using CurlDotNet;
using IronPdf;

// 1. Use CurlDotNet to handle the complex transport
// We use -k to allow insecure SSL (common in legacy internal apps)
var curlCommand = "curl -k https://internal-billing.local/invoice/1234 -H 'X-Dept: Sales'";
var response = await Curl.ExecuteAsync(curlCommand);

if (response.IsSuccess)
{
    // 2. Pass the raw bytes directly to IronPDF
    // IronPDF renders the PDF from the downloaded data
    var pdfDocument = PdfDocument.FromPdf(response.BodyBytes);

    // 3. Apply a watermark and save
    pdfDocument.ApplyWatermark("CONFIDENTIAL", 30, VerticalAlignment.Middle, HorizontalAlignment.Center);
    pdfDocument.SaveAs("Processed_Invoice.pdf");

    Console.WriteLine("Invoice downloaded and secured via IronPDF.");
}
using CurlDotNet;
using IronPdf;

// 1. Use CurlDotNet to handle the complex transport
// We use -k to allow insecure SSL (common in legacy internal apps)
var curlCommand = "curl -k https://internal-billing.local/invoice/1234 -H 'X-Dept: Sales'";
var response = await Curl.ExecuteAsync(curlCommand);

if (response.IsSuccess)
{
    // 2. Pass the raw bytes directly to IronPDF
    // IronPDF renders the PDF from the downloaded data
    var pdfDocument = PdfDocument.FromPdf(response.BodyBytes);

    // 3. Apply a watermark and save
    pdfDocument.ApplyWatermark("CONFIDENTIAL", 30, VerticalAlignment.Middle, HorizontalAlignment.Center);
    pdfDocument.SaveAs("Processed_Invoice.pdf");

    Console.WriteLine("Invoice downloaded and secured via IronPDF.");
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Console Confirmation

Confirmation written to console confirming the PDF is saved

PDF Output

Example output PDF file

Example 2: Scraping and OCR with IronOCR

IronOCR

IronOCR is an advanced optical character recognition library powered by the Tesseract 5 engine, fine-tuned specifically for C# and .NET. It supports over 127 languages and excels at reading text from imperfect sources—think low-resolution scans, rotated images, or noisy backgrounds. Its "Computer Vision" capabilities allow it to detect text regions automatically, and it can output data not just as plain strings, but as structured content (barcodes, paragraphs, lines, and characters) for deep analysis.

Sometimes you need to extract data from an image hosted on a server that blocks standard .NET scrapers. You can use CurlDotNet to mimic a standard browser user agent effortlessly, then use IronOCR to read the text.

using CurlDotNet;
using IronOcr;

// 1. Fetch the image using a specific browser User-Agent to bypass blocks
var imgResponse = await Curl.GetAsync("https://site.com/protected-captcha.png")
    .WithUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
    .ExecuteAsync();

// 2. Use IronOCR to read text from the file bytes
var ocr = new IronTesseract();
using (var input = new OcrInput())
{
    input.AddImage(imgResponse.BodyBytes);
    var result = ocr.Read(input);

    // 3. Output the extracted string value
    Console.WriteLine($"OCR Result: {result.Text}");
}
using CurlDotNet;
using IronOcr;

// 1. Fetch the image using a specific browser User-Agent to bypass blocks
var imgResponse = await Curl.GetAsync("https://site.com/protected-captcha.png")
    .WithUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
    .ExecuteAsync();

// 2. Use IronOCR to read text from the file bytes
var ocr = new IronTesseract();
using (var input = new OcrInput())
{
    input.AddImage(imgResponse.BodyBytes);
    var result = ocr.Read(input);

    // 3. Output the extracted string value
    Console.WriteLine($"OCR Result: {result.Text}");
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

OCR Example Output

Example output for using IronOCR with CurlDotNet

Example 3: Managing Inventory with IronBarcode

IronBarcode

IronBarcode is a versatile library designed to read and write virtually any barcode format, from standard UPCs and EANs to complex QR codes and Data Matrix tags. It is built for fault tolerance; the library includes automatic image correction filters that can sharpen, potential binarize, and rotate images to detect barcodes even if they are damaged, skewed, or poorly lit. This makes it an essential tool for logistics, retail, and industrial applications where hardware scanners aren't available.

In this scenario, we use CurlDotNet’s precise network control to fetch a label from a secure API, and IronBarcode's robust reading engine to verify the content instantly.

using CurlDotNet;
using IronBarCode;

class Program
{
    private static readonly HttpClient client = new HttpClient();
    public static async Task Main(string[] args)
    {

        // 1. Define the URL 
        string url = "https://barcodeapi.org/api/128/Shipping-Label-Test-123";

        try
        {
            // Add the session cookie to the request headers
            client.DefaultRequestHeaders.Add("Cookie", "session_id=xyz123");

            // 2. Download the image data as a Byte Array (Preserves binary integrity)
            byte[] imageBytes = await client.GetByteArrayAsync(url);

            Console.WriteLine($"Downloaded {imageBytes.Length} bytes.");

            // 3. Read the barcode directly from the byte array
            var result = BarcodeReader.Read(imageBytes);

            foreach (var barcode in result)
            {
                Console.WriteLine($"Detected Format: {barcode.BarcodeType}");
                Console.WriteLine($"Value: {barcode.Value}");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
}
using CurlDotNet;
using IronBarCode;

class Program
{
    private static readonly HttpClient client = new HttpClient();
    public static async Task Main(string[] args)
    {

        // 1. Define the URL 
        string url = "https://barcodeapi.org/api/128/Shipping-Label-Test-123";

        try
        {
            // Add the session cookie to the request headers
            client.DefaultRequestHeaders.Add("Cookie", "session_id=xyz123");

            // 2. Download the image data as a Byte Array (Preserves binary integrity)
            byte[] imageBytes = await client.GetByteArrayAsync(url);

            Console.WriteLine($"Downloaded {imageBytes.Length} bytes.");

            // 3. Read the barcode directly from the byte array
            var result = BarcodeReader.Read(imageBytes);

            foreach (var barcode in result)
            {
                Console.WriteLine($"Detected Format: {barcode.BarcodeType}");
                Console.WriteLine($"Value: {barcode.Value}");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronBarcode Console Output

Example output for using IronBarcode with CurlDotNet

Bringing "Userland" to .NET

The CurlDotNet bringing "Userland" concept to .NET is about more than just making requests. It allows you to use standard curl functionality in places like CI pipelines or docker containers running Linux macOS or windows.

You can use it to download files, upload data, or trigger webhooks using standard bash syntax within a DotNet run context. This bridges the gap between the command line tool world and your compiled application.

Conclusion: The End of the Translation Tax

It is not just about making HTTP requests; it is about respecting the developer’s time. Jacob Mellor and Iron Software understand that if a tool like curl has worked perfectly for 25 years, the .NET runtime should embrace it, not force you to reimplement it.

By adopting CurlDotNet, you aren't just adding a dependency; you are adopting a workflow that prioritizes shipping features over writing boilerplate. You stop "translating" and start executing. Whether you are grabbing a single JSON file or orchestrating complex iron software document workflows, the instruction remains the same: paste, run, done.

Next Steps

Stop wasting time translating headers and debugging HttpClient. Join the Userland.NET movement.

  1. Check the GitHub: Visit jacob-mellor/curl-dot-net to see the source code, documentation, and directory of examples.

  2. Download the NuGet Package: Run DotNet add package CurlDotNet to install the library.

  3. Explore Iron Software: See how IronPDF and IronOCR can work in tandem with CurlDotNet to accelerate your project.

By leveraging CurlDotNet, you ensure that your curl commands and your C# code speak the exact same language.