Convert cURL to Spring Boot

Paste any curl command and get Java code you can drop into a Spring Boot project. RestClient / WebClient calls with OkHttp under the hood. Runs entirely client-side.

Quick answer

To convert a cURL command to Java, paste it into the Toolpaper workbench below. It parses the command in your browser and emits idiomatic Java 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.

InputcURL command
MethodPOST·Headers1·Body40 B· Chars 132
OutputJVM · OkHttp(modern JVM)
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class Main {
  public static void main(String[] args) throws Exception {
    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
    clientBuilder.followRedirects(false).followSslRedirects(false);
    OkHttpClient client = clientBuilder.build();
    RequestBody body = RequestBody.create("{\"name\":\"Ada\",\"email\":\"ada@example.com\"}", MediaType.parse("application/json"));
    Request.Builder rb = new Request.Builder().url("https://api.example.com/users");
    rb.method("POST", body);
    rb.header("Content-Type", "application/json");
    try (Response response = client.newCall(rb.build()).execute()) {
      System.out.println(response.body().string());
    }
  }
}
Inspect

Example

A representative curl command for this scenario. Paste your own above to convert an exact match.

curl input
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"Ada","email":"ada@example.com"}'

Implementation notes

  • Generated code uses the OkHttp primitive that fits Spring Boot's idioms — you can drop it into a controller, action, or service.
  • Errors and timeouts propagate naturally so you can wrap the call in Spring Boot's middleware and observability layer.
  • Environment variables replace inline secrets when you run the output through the Clean panel first.

Common mistakes

  • Blocking a request-scoped Spring Boot handler on a slow upstream — always set a timeout in the generated call.
  • Recreating an HTTP client per request instead of reusing a module-level one — kills keep-alive performance.
  • Leaking request-scoped headers (auth, tracing) to upstream calls — the generator only forwards what you paste.

Common questions

Which Java library does the Spring Boot output use?
OkHttp, because it's the idiomatic choice inside Spring Boot. Switch libraries in the language dropdown any time.
Can I use this in a serverless function?
Yes. The generated code is a plain Java function; deploy it on Spring Boot's serverless target of choice.
Is any data sent to Toolpaper's servers?
No. Parsing and code generation run entirely in your browser.

Full Java reference on the cURL to Java hub, or open the main converter for all 18 targets.