Convert curl commands to Ruby Net::HTTP code instantly. Free online curl to Ruby converter that handles headers, authentication, and request bodies.
The converter generates Ruby code that uses Net::HTTP from the standard library. No gems, no Bundler, no Gemfile. The output works with a stock Ruby installation. This makes it ideal for quick scripts, one-off API calls, and environments where adding dependencies is not practical.
The generated code creates a URI object, builds the appropriate request class (Net::HTTP::Get, Net::HTTP::Post, etc.), sets headers and body, and sends the request. The output includes both the response code and the response body.
If you prefer using a higher-level library like Faraday or HTTParty, the generated code serves as a clear reference for the headers, body, and authentication values you need.
| Curl flag | Ruby Net::HTTP equivalent |
|---|---|
| -X POST | Net::HTTP::Post.new(uri) |
| -H 'Key: Value' | request["Key"] = "Value" |
| -d '{"key":"val"}' | request.body = '{"key":"val"}' |
| -u user:pass | request.basic_auth("user", "pass") |
| -k | http.verify_mode = OpenSSL::SSL::VERIFY_NONE |
| -b 'cookie=val' | Added as request["Cookie"] |
The generated code automatically sets http.use_ssl = true when the URL uses HTTPS. If the curl command includes -k or --insecure, the code adds http.verify_mode = OpenSSL::SSL::VERIFY_NONE to skip certificate verification.
For production code, always use SSL verification. The -k flag is useful for development environments with self-signed certificates but should not be used in production.
Basic auth from -u user:pass maps to request.basic_auth("user", "pass"), which is a built-in method on all Net::HTTP::Request subclasses. This is cleaner than manually encoding the credentials and setting the Authorization header.
Bearer tokens and API keys sent via -H 'Authorization: Bearer token' are preserved as regular headers in the generated code. The converter does not alter authentication headers. What goes in is what comes out.
Net::HTTP is Ruby's built-in HTTP client. It requires no gems, works everywhere Ruby runs, and gives you full control over the request. The downside is its verbose API. Setting up a request takes several lines compared to Faraday or HTTParty.
If your project already uses Faraday or HTTParty, the generated code is still valuable as a reference. The headers hash, body string, and auth values translate directly to any Ruby HTTP library. The converter uses Net::HTTP because it is available without dependencies.
Paste your curl command into the input field above, select "Ruby," and click Convert. The output uses Net::HTTP from Ruby's standard library and requires no external gems.
Yes. The generated Net::HTTP code works in any Ruby environment, including Rails applications, Rake tasks, and background jobs. You can paste it directly into a service object or controller action.
No. The output uses only net/http and uri from Ruby's standard library. No Gemfile changes are needed.
No. All conversion happens in your browser. Nothing leaves your machine.
Yes. The headers hash and body string from the generated code work with any Ruby HTTP library. Replace the Net::HTTP calls with Faraday's conn.post or conn.get using the same values.
Structured page data instead of raw HTML. Your agent processes less, decides faster, and costs less to run.