cURL to R Converter
Convert curl commands to R code using httr or httr2. Paste a command and the R 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 R httr code appears instantly; other R libraries (httr2) are in the tabs above the code.
- Set up: Install with
install.packages("httr"). - Run it: Run the script in R or RStudio. Replace placeholders such as
YOUR_TOKENfirst, and check any notes under the editors for curl options that have no httr equivalent.
Example
GET with headers → R httr
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'library(httr)
response <- GET(
"https://api.example.com/v1/users?page=2",
add_headers(.headers = c(
"Accept" = "application/json",
"Authorization" = "Bearer YOUR_TOKEN"
))
)
print(status_code(response))
cat(content(response, as = "text", encoding = "UTF-8"), "\n")Common use cases
- Existing R code using httr
- Pulling API data into data frames
Converting curl to R httr
httr is a long-standing R package for HTTP. It's now superseded by httr2 but still widely used.
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 httr code. Options that have no httr equivalent are listed under the editors rather than silently dropped.
Other libraries for R, each with its own page: httr2.
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
httr or httr2?
httr2 is the successor and recommended for new code — see cURL to R httr2.
How do I parse JSON?
Use content(response, as = "parsed") or jsonlite::fromJSON on the text.
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.