Convert curl to Julia

curl2code converts curl commands to Julia code using HTTP.jl. The conversion runs in your browser via WebAssembly for complete privacy. For Python, check our curl to Python converter. For R, see curl to R. Below are practical Julia examples.

How to copy curl from your browser

  1. 1

    Open DevTools

    Press F12 or Ctrl+Shift+I to open your browser developer tools.

  2. 2

    Go to the Network tab

    Click the Network tab and perform the action that triggers the HTTP request.

  3. 3

    Copy as cURL

    Right-click the request → CopyCopy as cURL. Then paste it above.

Frequently Asked Questions

What is Julia HTTP.jl?

HTTP.jl is the standard HTTP client and server package for Julia. It provides a simple, high-level API with connection pooling, cookie handling, and streaming support. Install with using Pkg; Pkg.add("HTTP"). It integrates well with Julia's multiple dispatch system. curl2code uses HTTP.jl for all Julia conversions.

HTTP.jl vs Downloads.jl vs LibCURL.jl — which to use?

HTTP.jl is the full-featured HTTP client — use for APIs and custom requests. Downloads.jl is a stdlib module for simple file downloads. LibCURL.jl wraps libcurl for curl-specific features. For most tasks, HTTP.jl is the right choice. For similar scientific computing clients, see curl to Python or curl to R.

How to handle authentication in Julia?

Pass headers as a vector of pairs: HTTP.get(url, ["Authorization" => "Bearer $token"]). For Basic auth: ["Authorization" => "Basic $(base64encode("$user:$pass"))"]. Julia's string interpolation with $ makes header construction clean. curl2code converts auth flags to Julia syntax.

How to send multipart form data in Julia?

Use HTTP.Form: HTTP.post(url, body=HTTP.Form(["file" => open("doc.pdf"), "desc" => "My file"])). HTTP.jl handles multipart encoding, boundaries, and Content-Type automatically. curl2code converts -F flags to the HTTP.jl Form syntax.

How to handle HTTP errors in Julia?

HTTP.jl throws HTTP.StatusError on non-2xx responses by default. Disable with status_exception=false to get the response directly. Use try ... catch e for error handling. Check e.status for the HTTP code. Network errors throw HTTP.IOError.

How to make concurrent HTTP requests in Julia?

Use @async tasks: tasks = [@async HTTP.get(url) for url in urls], then responses = fetch.(tasks). For true parallelism, use Threads.@threads or Distributed. Julia's coroutine-based tasks are efficient for I/O-bound concurrent requests.

How to set timeouts in Julia?

Pass the readtimeout keyword: HTTP.get(url, readtimeout=30). For connection timeout, use connect_timeout. For retries, use retry=true with retries=3. HTTP.jl has built-in retry with exponential backoff. These map to curl's --max-time and --connect-timeout.

How to use a proxy in Julia?

Pass the proxy keyword: HTTP.get(url, proxy="http://proxy:8080"). HTTP.jl also respects HTTP_PROXY and HTTPS_PROXY environment variables by default. For authenticated proxies, include credentials in the proxy URL: http://user:pass@proxy:8080.

How to send a POST request with JSON body in Julia?

Convert a curl POST command like curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' URL to Julia using curl2code. The generated code uses HTTP.post(url, ['Content-Type' => 'application/json'], JSON3.write(data)). curl2code automatically detects -d/--data flags with JSON content and sets the appropriate Content-Type header in the HTTP.jl code.

How to add Bearer token authorization in Julia?

Pass curl -H "Authorization: Bearer YOUR_TOKEN" URL to curl2code and it generates HTTP.jl code with the auth header: ['Authorization' => 'Bearer YOUR_TOKEN']. curl2code detects Bearer tokens from both -H "Authorization: Bearer ..." and --oauth2-bearer flags. For Basic auth, use -u user:pass.

How to set Content-Type header in Julia?

curl2code converts curl -H "Content-Type: application/json" URL to HTTP.jl code with the proper header: ['Content-Type' => 'application/json']. For -d data, curl defaults to application/x-www-form-urlencoded; for -F form uploads, it uses multipart/form-data. curl2code maps each to the correct HTTP.jl API.

Useful Links

curl Guides

Convert curl to Other Languages