Skip to content

cURL to Code

Convert a "Copy as cURL" command into fetch, Axios, Laravel Http or Guzzle client code, with headers and body kept intact, live in your browser.

Generated files

Generated code appears here.

Diagnostics appear here after you paste your input.

Processed locally in your browser. Your data never leaves your device.

About this curl to code converter

Paste a curl command and get working client code: the method, URL, query string, headers, body and basic auth carried over exactly, in fetch, Axios, Laravel's Http facade or Guzzle. It reads the command as text, so it works directly from a browser's "Copy as cURL", from API documentation, or typed by hand.

A worked example

This curl command:

curl 'https://api.example.com/v1/users?active=true' \
  -H 'accept: application/json' \
  -H 'content-type: application/json' \
  -H 'authorization: Bearer abc.def.ghi' \
  --data-raw '{"name":"Ada Lovelace","role":"admin"}'

becomes, as fetch:

const response = await fetch("https://api.example.com/v1/users?active=true", {
    method: "POST",
    headers: {
        accept: "application/json",
        "content-type": "application/json",
        authorization: "Bearer abc.def.ghi",
    },
    body: "{\"name\":\"Ada Lovelace\",\"role\":\"admin\"}",
})

The method defaults to POST because a body is present (curl does the same); -X/--request always overrides it explicitly. Axios keeps the query string as a separate params option instead of appending it to the URL; Laravel Http and Guzzle both read the JSON body into a real PHP array literal, not a string, when the content type says JSON.

How to use it

  1. Paste a curl command, drop a file, or load an example.
  2. Choose an output (fetch, Axios, Laravel Http or Guzzle) in the Output menu.
  3. Read the diagnostics: they explain anything ignored, such as a client certificate or an unrecognized flag.
  4. Copy or download the generated file.

What gets carried over

  • Method, URL and query string, including a query string that curl builds itself with -G/--get.
  • Headers, with repeated -H flags for the same name merged the way curl itself sends them.
  • A text body (-d/--data, concatenated if repeated, --data-urlencode encoded) or a multipart form (-F/--form), with file fields (name=@file) marked as files rather than inlined, since the file was never read.
  • Basic auth (-u/--user) as each target's idiomatic auth option.

Frequently asked questions

Where do I get a curl command to paste?
Open your browser's DevTools (F12), go to the Network tab, make the request, right-click it and choose "Copy as cURL". Most API docs and Postman also offer a "curl" or "Copy as cURL" export. Paste whatever comes out; the parser handles the usual multi-line, backslash-continued shape those tools produce.
Does it run the request?
No. It only reads the curl command's text and turns it into equivalent client code. Nothing is sent anywhere.
What happens to flags it does not understand?
Anything that changes what request is sent (headers, method, body, auth, query) is read. Anything that only affects how curl itself behaves (verbose output, following redirects, TLS options, writing to a file) is quietly ignored, except when ignoring it changes behaviour that matters: a client certificate or a disabled TLS check produces a diagnostic instead of silently vanishing. A flag it does not recognize at all is flagged as unsupported rather than guessed at.
Does it handle -d, --data-raw, --data-urlencode and file uploads?
Yes. Repeated -d/--data flags are concatenated (curl's own behaviour), --data-urlencode form-encodes its value, and -F/--form builds a multipart body; a field written as name=@file.png is recognized as a file and the generated code marks it as one instead of inlining file contents that were never read.
Which output should I use?
fetch if you don't want a dependency (built into every modern browser and Node). Axios if your project already uses it, for its params/data split and interceptors. Laravel's Http facade for server-side PHP inside a Laravel app. Guzzle for PHP outside Laravel, or where you need Guzzle-specific options.