Convert curl to Ruby

Instantly convert your curl commands to Ruby code using the Net::HTTP library. Free, fast, and no signup required.

Examples:
Type or paste a curl command and click 'Convert' to see the code.
Target language:

Enter a curl command and click Convert to see the Ruby code

About Ruby HTTP Requests

Ruby's Net::HTTP is part of the standard library and provides everything needed to make HTTP requests. While the API can be verbose, it's dependency-free and available in all Ruby installations. For a more elegant API, many Rubyists prefer gems like Faraday or HTTParty, but Net::HTTP remains a solid choice for keeping dependencies minimal.

Key Features

  • Part of Ruby standard library
  • No gem dependencies required
  • Support for all HTTP methods
  • SSL/TLS support built-in
  • Proxy support
  • Persistent connections
  • Streaming response bodies

View official Net::HTTP documentation

Frequently Asked Questions

How do I convert a curl command to Ruby?

Paste your curl command in the input box and click "Convert". The tool generates Ruby code using Net::HTTP from the standard library.

Should I use Net::HTTP or a gem like Faraday?

Net::HTTP works without dependencies. For more complex applications, Faraday or HTTParty provide cleaner APIs with middleware support. This tool generates stdlib code for maximum compatibility.

How do I parse JSON responses in Ruby?

Use the built-in JSON module: JSON.parse(response.body). This returns a Ruby Hash. Require 'json' at the top of your file.

Does the code handle HTTPS automatically?

Yes! The generated code checks if the URI scheme is 'https' and sets use_ssl accordingly when starting the HTTP connection.

How do I add timeouts to Ruby HTTP requests?

Set http.open_timeout and http.read_timeout on the Net::HTTP object before making the request.

Convert curl to Other Languages