Convert cURL to Rails
Paste any curl command and get Ruby code you can drop into a Rails project. Service objects using net/http or Faraday. Runs entirely client-side.
Quick answer
To convert a cURL command to Ruby, paste it into the Toolpaper workbench below. It parses the command in your browser and emits idiomatic Ruby code — headers, query string, request body, authentication (Bearer, Basic, API key), and cookies are all wired up automatically. No data is uploaded; conversion is fully client-side.
InputcURL command
MethodPOST·Headers1·Body40 B· Chars 132
OutputRuby · net/http(stdlib)
require 'net/http'
require 'uri'
require 'json'
uri = URI("https://api.example.com/users")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/json"
request.body = "{\"name\":\"Ada\",\"email\":\"ada@example.com\"}"
response = http.request(request)
puts response.bodyInspect
Example
A representative curl command for this scenario. Paste your own above to convert an exact match.
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Ada","email":"ada@example.com"}'Implementation notes
- Generated code uses the net/http primitive that fits Rails's idioms — you can drop it into a controller, action, or service.
- Errors and timeouts propagate naturally so you can wrap the call in Rails's middleware and observability layer.
- Environment variables replace inline secrets when you run the output through the Clean panel first.
Common mistakes
- Blocking a request-scoped Rails handler on a slow upstream — always set a timeout in the generated call.
- Recreating an HTTP client per request instead of reusing a module-level one — kills keep-alive performance.
- Leaking request-scoped headers (auth, tracing) to upstream calls — the generator only forwards what you paste.
Common questions
- Which Ruby library does the Rails output use?
- net/http, because it's the idiomatic choice inside Rails. Switch libraries in the language dropdown any time.
- Can I use this in a serverless function?
- Yes. The generated code is a plain Ruby function; deploy it on Rails's serverless target of choice.
- Is any data sent to Toolpaper's servers?
- No. Parsing and code generation run entirely in your browser.
Full Ruby reference on the cURL to Ruby hub, or open the main converter for all 18 targets.