Convert a cURL PUT request to Rust
Paste any curl PUT command and get clean Rust code using reqwest. Runs entirely in your browser — headers, auth, and JSON bodies map to idiomatic Rust.
Quick answer
To convert a cURL command to Rust, paste it into the Toolpaper workbench below. It parses the command in your browser and emits idiomatic Rust 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.
Prefer a different target? See the full cURL to Rust reference, or jump to the same guide in JavaScript, Node.js, or Python.
// Cargo.toml: reqwest = { version = "0.12", features = ["json", "blocking", "gzip", "brotli"] }
use reqwest::blocking::Client;
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
use std::str::FromStr;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder().redirect(reqwest::redirect::Policy::none()).build()?;
let mut headers = HeaderMap::new();
headers.insert(HeaderName::from_str("content-type")?, HeaderValue::from_str("application/json")?);
let mut req = client.put("https://api.example.com/users/42").headers(headers);
req = req.body("{\"name\":\"Ada Lovelace\"}");
let resp = req.send()?;
println!("{}", resp.text()?);
Ok(())
}Example
A representative curl command for this scenario. Paste your own above to convert an exact match.
curl -X PUT https://api.example.com/users/42 \
-H "Content-Type: application/json" \
-d '{"name":"Ada Lovelace"}'Implementation notes
- Request-line method (PUT) and target URL are extracted from the curl command exactly as written — no case-folding, no path rewriting.
- Every -H header maps to a Rust header entry; duplicates are preserved so servers that read multi-valued headers keep behaving.
- Query strings in the URL stay in the URL; -G with --data-urlencode is promoted to a structured params argument where reqwest supports it.
- Request bodies are parsed against Content-Type: JSON bodies use idiomatic serialization (reqwest), form bodies use URL-encoding, multipart uses -F semantics with file@ handling.
- TLS flags (--insecure, --cacert, --cert) surface as inline notes so you don't ship an insecure client to production by accident.
Common mistakes
- Forgetting that -X PUT without a body still sends an empty body — the generated code mirrors that exactly.
- Assuming curl auto-follows redirects: it doesn't. Add -L (or the generator's follow-redirects flag) if you actually need to chase 3xx responses.
- Copying a Cookie header from DevTools that already encodes session state — use the Clean panel to strip session cookies before you share.
Common questions
- How do I send a PUT request in Rust?
- Paste your curl PUT command above. Toolpaper generates Rust using reqwest with headers, query string, and (where applicable) request body wired up.
- Does the PUT generator handle authentication?
- Yes — Authorization headers, Bearer tokens, Basic auth (-u), and API keys pass through to the generated Rust code unchanged.
- Is my curl sent to a server?
- No. Parsing and code generation run in your browser. Nothing is uploaded.
- Can I also convert this to other languages?
- Yes. Once you paste your command, the language picker lets you switch between 18 targets (fetch, axios, Python, Go, PHP, Ruby, Rust, Java, Kotlin, C#, PowerShell, Swift and more).
More cURL methods in Rust
Rust hub →The same guide in other languages
All guides →Full Rust reference on the cURL to Rust hub, or open the main converter for all 18 targets.