cURL to Elixir Converter
Convert curl commands to Elixir code using HTTPoison. Paste a command and the Elixir 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 Elixir HTTPoison code appears instantly.
- Set up: Add
:httpoisonto your deps inmix.exs, or useMix.install([:httpoison])in a script. - Run it: Run the script with
elixir request.exs, or call the code from your application. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no HTTPoison equivalent.
Example
GET with headers → Elixir HTTPoison
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'url = "https://api.example.com/v1/users?page=2"
headers = [
{"Accept", "application/json"},
{"Authorization", "Bearer YOUR_TOKEN"}
]
body = ""
options = []
case HTTPoison.request(:get, url, body, headers, options) do
{:ok, %HTTPoison.Response{status_code: status, body: resp_body}} ->
IO.puts(status)
IO.puts(resp_body)
{:error, %HTTPoison.Error{reason: reason}} ->
IO.inspect(reason, label: "Request failed")
endCommon use cases
- Phoenix applications calling external APIs
- Elixir scripts and background jobs
Converting curl to Elixir HTTPoison
HTTPoison is a popular Elixir HTTP client built on hackney; requests return {:ok, response} or {:error, reason}.
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 HTTPoison code. Options that have no HTTPoison 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 a case statement?
HTTPoison returns tagged tuples, so the code handles both the response and connection errors.
How do I decode JSON?
Use a JSON library such as Jason: Jason.decode!(resp_body).
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.