cURL to F# Converter
Convert curl commands to F# code using HttpClient. Paste a command and the F# snippet appears instantly — everything runs in your browser.
- Instant ConversionCode updates as you type
- Multiple Languages40 languages, 61 libraries
- 100% Client SideYour data stays private
How to use this tool
Steps for using the cURL to Code.
- Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
- Paste it into Enter cURL command. The F# HttpClient code appears instantly.
- Set up: Install the .NET SDK 6 or later —
HttpClientis part of it, so there are no packages to add. - Run it: Save the code as
Program.fsxand rundotnet fsi Program.fsx. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no HttpClient equivalent.
Example
GET with headers → F# HttpClient
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'open System
open System.Net.Http
let client = new HttpClient()
let request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/v1/users?page=2")
request.Headers.TryAddWithoutValidation("Accept", "application/json") |> ignore
request.Headers.TryAddWithoutValidation("Authorization", "Bearer YOUR_TOKEN") |> ignore
let response = client.Send(request)
printfn "%d" (int response.StatusCode)
printfn "%s" (response.Content.ReadAsStringAsync().Result)Common use cases
- F# scripts and data notebooks
- F# services calling REST APIs
Converting curl to F# HttpClient
HttpClient is .NET's built-in HTTP client. The F# code builds an HttpRequestMessage, sends it with client.Send and prints the status and body.
The converter reads the curl command the way curl does — the method (-X), headers (-H), request bodies (-d, --data-raw, --json, -F), query strings, basic auth (-u) and cookies — and writes the equivalent HttpClient code. Options that have no HttpClient equivalent are listed under the editors rather than silently dropped.
Limitations
- The code is a starting point: add timeouts, retries and error handling for production use.
- Secrets in the curl command are copied into the code — move them to environment variables before committing.
Frequently asked questions
Why |> ignore after TryAddWithoutValidation?
The method returns true or false. F# warns when a result is silently discarded, so |> ignore says it isn't needed.
Should I use async code?
In an application, yes: use client.SendAsync inside a task { } block. The script uses the synchronous Send to stay short.
Should I create a new HttpClient for every request?
No. Create one and reuse it, so connections are pooled.
Is my curl command sent to a server?
No. The conversion runs entirely in your browser, so tokens and passwords in the command never leave your device. Still, replace real secrets before sharing the generated code.