Convert curl to Java

Paste your curl command below — the Java · HttpClient code is generated instantly, entirely in your browser.

// your code will appear here

How the curl to Java conversion works

The output uses the modern java.net.http.HttpClient API (Java 11+): the URL and method build an HttpRequest, each -H flag becomes a .header(...) call, and -d becomes a BodyPublishers.ofString body.

Example

curl -X POST https://api.example.com/orders \
  -H 'Content-Type: application/json' \
  -d '{"item": "coffee", "qty": 2}'

becomes a complete, runnable Main class using HttpRequest.newBuilder() — paste your command above to see it.