cURL to Scala Converter
Convert curl commands to Scala code using sttp. Paste a command and the Scala snippet appears instantly — everything runs in your browser.
- Instant ConversionCode updates as you type
- Multiple Languages40 languages, 61 libraries
- 100% Client SideYour data stays private
How to use this tool
Steps for using the cURL to Code.
- Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
- Paste it into Enter cURL command. The Scala sttp code appears instantly.
- Set up: Install Scala CLI. The
//> usinglines at the top fetch Scala 3 and sttp when the script runs. In sbt, add"com.softwaremill.sttp.client4" %% "core" % "4.0.0". - Run it: Save the code as
Main.scalaand runscala-cli Main.scala. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no sttp equivalent.
Example
GET with headers → Scala sttp
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'//> using scala 3
//> using dep com.softwaremill.sttp.client4::core:4.0.0
import sttp.client4.quick.*
import sttp.model.{Method, Uri}
@main def run(): Unit =
val response = quickRequest
.method(Method.GET, Uri.unsafeParse("https://api.example.com/v1/users?page=2"))
.header("Accept", "application/json")
.header("Authorization", "Bearer YOUR_TOKEN")
.send()
println(response.code)
println(response.body)Common use cases
- Scala services and scripts
- Spark or data jobs that call APIs
Converting curl to Scala sttp
sttp client4 is a popular Scala HTTP client. The code uses its synchronous quick API: quickRequest builds the request and .send() returns the status and body as a string.
The converter reads the curl command the way curl does — the method (-X), headers (-H), request bodies (-d, --data-raw, --json, -F), query strings, basic auth (-u) and cookies — and writes the equivalent sttp code. Options that have no sttp equivalent are listed under the editors rather than silently dropped.
Limitations
- The code is a starting point: add timeouts, retries and error handling for production use.
- Secrets in the curl command are copied into the code — move them to environment variables before committing.
Frequently asked questions
Why Uri.unsafeParse instead of uri"…"?
The uri"…" interpolator treats $ as a variable, so URLs that contain it would change. Uri.unsafeParse keeps the URL exactly as in curl.
Is the request blocking?
Yes, the quick API uses a synchronous backend. For async code, use a Future, cats-effect or ZIO backend with the same request.
Is my curl command sent to a server?
No. The conversion runs entirely in your browser, so tokens and passwords in the command never leave your device. Still, replace real secrets before sharing the generated code.