cURL to Haskell Converter
Convert curl commands to Haskell code using http-conduit. Paste a command and the Haskell 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 Haskell http-conduit code appears instantly.
- Set up: Install GHC and cabal (for example with GHCup). The dependencies are listed in the
{- cabal: -}block at the top of the code. - Run it: Save the code as
Main.hsand runcabal run Main.hs. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no http-conduit equivalent.
Example
GET with headers → Haskell http-conduit
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'{- cabal:
build-depends: base, bytestring, http-conduit
-}
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy.Char8 as L8
import Network.HTTP.Simple
main :: IO ()
main = do
initReq <- parseRequest "GET https://api.example.com/v1/users?page=2"
let request
= setRequestHeader "Accept" ["application/json"]
$ setRequestHeader "Authorization" ["Bearer YOUR_TOKEN"]
$ initReq
response <- httpLBS request
print (getResponseStatusCode response)
L8.putStrLn (getResponseBody response)Common use cases
- Haskell CLIs and services
- Scripts that call REST APIs
Converting curl to Haskell http-conduit
http-conduit provides Network.HTTP.Simple, the usual way to make HTTP requests in Haskell. The code parses the method and URL with parseRequest, adds headers and a body with setRequest… functions, and sends it with httpLBS.
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 http-conduit code. Options that have no http-conduit 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 OverloadedStrings?
It lets string literals be used as ByteString headers and bodies. Text that isn't plain ASCII is UTF-8 encoded with TE.encodeUtf8, because a ByteString literal would keep only the low byte of each character.
Does httpLBS throw on 404 or 500?
No. parseRequest doesn't throw on error status codes, so the code prints the status for you to check. parseRequestThrow throws instead.
How do I decode a JSON response?
Use httpJSON with a type that has an aeson FromJSON instance instead of httpLBS.
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.