cURL converter · Ruby
cURL to Ruby
Paste a curl command and get idiomatic Ruby. Uses net/http, matches the correct verb subclass (Get, Post, Put, Delete, Patch), and wires basic auth through request.basic_auth.
InputcURL command
1 secret
MethodPOST·Headers2·Body46 B· Chars 187
OutputRuby · net/http(stdlib)
require 'net/http'
require 'uri'
require 'json'
uri = URI("https://api.example.com/v1/messages")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
request = Net::HTTP::Post.new(uri.request_uri)
request["Authorization"] = "Bearer sk_test_123"
request["Content-Type"] = "application/json"
request.body = "{\"to\":\"+15551234567\",\"body\":\"Hello from curl\"}"
response = http.request(request)
puts response.bodyInspect
Top guides for Ruby
All guides →Common questions
- Why not Faraday or HTTParty?
- net/http is in the standard library, so the snippet drops in anywhere. Tell us if you'd like Faraday or HTTParty variants.
- Basic auth?
- -u user:pass becomes request.basic_auth('user', 'pass') — never a raw base64 string in your source.
- TLS options?
- --insecure sets http.verify_mode = OpenSSL::SSL::VERIFY_NONE. Remove that line once you're back on a valid cert.
- Is my curl sent anywhere?
- No. Everything runs in your browser.
Also convert cURL to
All guides →Same parser, same idiomatic output — swap the target language whenever your stack changes. Every hub carries its own reference guides for methods, payloads, and auth.