cURL → Ruby
Convert cURL HTTP requests into clean, native Ruby code using Net::HTTP, URI, Faraday, and JSON request/response handling.

cURL to Ruby (Net::HTTP & Faraday) Code Generator

Convert cURL HTTP requests into clean, native Ruby code using Net::HTTP, URI, Faraday, and JSON request/response handling.

100% Client-Side Privacy
Zero Server Transmission
Presets:
cURL Command InputPOST
#!/usr/bin/env ruby
# Net::HTTP Client - Ruby Standard Library (Zero External Gems)
require 'net/http'
require 'uri'
require 'json'

begin
  uri = URI.parse("https://api.github.com/repos/octocat/Hello-World/issues")

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = (uri.scheme == 'https')

  request = Net::HTTP::Post.new(uri.request_uri)
  request["Accept"] = "application/vnd.github+json"
  request["Authorization"] = "Bearer gho_16C7e42F292c6912E7710c838347Ae178B4a"
  request["X-GitHub-Api-Version"] = "2022-11-28"
  request["Content-Type"] = "application/json"

  payload = {
    title: "Bug in auth session",
    body: "Need to verify token expiration handling",
    labels: ["bug", "priority"]
  }
  request.body = JSON.dump(payload)

  # Dispatch request
  response = http.request(request)

  puts "HTTP Status: #{response.code} #{response.message}"
  begin
    data = JSON.parse(response.body)
    puts "Parsed JSON Response:"
    puts JSON.pretty_generate(data)
  rescue JSON::ParserError
    puts "Raw Body: #{response.body}"
  end
rescue SocketError => e
  warn "Network connection error: #{e.message}"
rescue Net::OpenTimeout, Net::ReadTimeout => e
  warn "Request timed out: #{e.message}"
rescue StandardError => e
  warn "Execution failure: #{e.class} - #{e.message}"
end

100% Client-Side Privacy

All cURL parsing, API token extraction, and Ruby code generation happen entirely in your browser memory. Zero network payloads sent to servers.

Net::HTTP & Faraday Dual Engines

Generate dependency-free standard library Net::HTTP scripts, modern Faraday blocks, HTTParty, or HTTP.rb with full middleware and SSL options.

Production Payload Parity

Flawlessly handles JSON payloads, form URL-encoded bodies, multipart uploads, HTTP Basic/Bearer auth, redirects, and custom timeouts.

Technical Reference & Architecture Guide

cURL to Ruby (Net::HTTP & Faraday) Code Generator — Reference Guide

Convert cURL HTTP requests into clean, native Ruby code using Net::HTTP, URI, Faraday, and JSON request/response handling.

Key Parameters & Controls

librarystring (net_http | faraday)

Target Ruby HTTP client library to generate code for.

Default: net_http
cleanDevToolsboolean

Strips browser DevTools pseudo-headers (:authority, :method, :path) that break Ruby HTTP parsers.

Default: true
parseJsonboolean

Appends JSON.parse with symbolize_names: true to parse response bodies into idiomatic Ruby hashes.

Default: true
sslVerifyboolean

Configures SSL peer certificate verification mode (VERIFY_PEER vs VERIFY_NONE).

Default: true

Pro Tips & Best Practices

When using Net

When using Net::HTTP directly with Net::HTTP.new(uri.host, uri.port), SSL is disabled by default. Always call http.use_ssl = (uri.scheme == 'https') or use the block form Net::HTTP.start(uri.host, uri.port, use_ssl: true) to avoid cleartext connection failures.

Leverage Faraday Middleware and Adapters

Faraday provides composable middleware for automatic JSON serialization, response parsing, and retries. Use Faraday.new with f.request :json and f.response :json to keep business logic decoupled from HTTP transport.

Calling JSON.parse

Calling JSON.parse(response.body, symbolize_names: true) produces symbol keys (e.g. data[:id] instead of data['id']). This aligns with Ruby naming conventions and reduces string memory allocation.

Common Gotchas & Troubleshooting

Net::HTTPHeaderSyntaxError: invalid header name or value

Browser DevTools export HTTP/2 pseudo-headers starting with a colon (e.g. :authority, :path). Enable 'cleanDevTools' to prune pseudo-headers before Ruby Net::HTTP constructs headers.

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 peer certificate cannot be authenticated

Ensure your Ruby environment has access to updated CA certificates via certifi or your system trust store. For local testing with self-signed certificates, set http.verify_mode = OpenSSL::SSL::VERIFY_NONE.

Frequently Asked Questions

When should I choose Net::HTTP over Faraday in Ruby?▼

Choose Net::HTTP when building lightweight standalone scripts, Ruby gems where external gem dependencies must be avoided, or AWS Lambda serverless functions. Choose Faraday for Rails applications and API clients that benefit from connection pooling, middleware, and flexible HTTP adapters.

How does the generator handle HTTP basic authentication and bearer tokens?▼

cURL flags like -u user:pass or --user are converted into req.basic_auth(user, pass) in Net::HTTP or f.request :authorization, :basic in Faraday. Bearer tokens in headers are mapped directly to standard Authorization: Bearer <token> headers.

How can I stream large file downloads or payloads in Ruby?▼

In Net::HTTP, pass a block to http.request(req) { |res| res.read_body { |chunk| file.write(chunk) } } to stream chunks directly to disk. In Faraday, configure a streaming adapter or block to avoid loading large payloads into memory.

Is my cURL command data sent to any remote server for conversion?▼

No. All cURL parsing, header sanitization, and Ruby code generation execute 100% in your local browser using client-side JavaScript. No tokens, URLs, or request payloads are ever logged or uploaded.

Related Tools & Utilities

All Tools →