Esta página ainda não foi traduzida para o português, por isso aparece em inglês.

cURL to Code Converter

Paste a curl command — from API docs or “Copy as cURL” in your browser’s DevTools — and get ready-to-run code for six languages, with headers, body and authentication carried over.

Atualizado em

  

Seus dados nunca saem do seu computador. Todo o processamento acontece localmente no navegador.

Como usar: cURL to Code

  1. Copy a request as curl — in Chrome or Firefox DevTools right-click a request in the Network tab and choose Copy › Copy as cURL — or take a curl example from API documentation.
  2. Paste it into the curl command box. Multi-line commands with \ continuations are fine.
  3. Pick a language tab: JavaScript fetch, Axios, Node.js, Python, PHP or Go.
  4. Read the notes below the code for anything that needs your attention, then click Copy code.

What does a curl to code converter do?

curl is the universal language of HTTP examples: API documentation, Postman exports and every browser’s “Copy as cURL” feature produce curl commands. Translating one by hand into your application’s language means re-typing headers, escaping JSON and remembering how each HTTP client handles forms and authentication. This converter parses the command the way a POSIX shell and curl would, then generates idiomatic code for the client library you use.

Supported curl options

OptionConverted to
-X, --requestHTTP method (otherwise GET, or POST when a body is present)
-H, --header, -A, -e, -bRequest headers, including User-Agent, Referer and Cookie
-d, --data, --data-raw, --data-binary, --data-urlencodeRequest body (form-encoded by default, like curl); @file reads a file
--jsonJSON body with Content-Type and Accept: application/json
-F, --formMultipart form data, including file uploads with ;type= and ;filename=
-u, --user, --oauth2-bearerBasic authentication or a Bearer token
-G, --get, --url-queryData appended to the URL query string
-I, -L, -k, -m, -x, --compressedHEAD requests, redirects, TLS verification, timeouts, proxies and compression where the library supports them

Quoting follows shell rules: single quotes, double quotes with backslash escapes, ANSI-C $'…' strings (Chrome uses these for bodies containing quotes) and line continuations. Windows “Copy as cURL (cmd)” commands with ^ escapes are detected and converted too. Output-only flags such as -s, -v or -o are ignored, and anything unsupported is listed in the notes rather than silently dropped.

Choosing a target

  • JavaScript fetch — built into every browser. Cross-origin requests also need the server to send CORS headers, and browsers refuse to set headers like Cookie or Host; the converter warns you when that applies.
  • Node.js fetch — built into Node 18+, no dependency needed; file uploads use fs.openAsBlob.
  • Axios — popular for its interceptors and automatic JSON handling.
  • Python requests — JSON bodies become native dictionaries passed with json=; forms become data= dicts.
  • PHP cURL — uses curl_setopt_array with the matching CURLOPT_* constants, ideal for WordPress or Laravel code without extra packages.
  • Go net/http — a complete runnable main.go with error handling and multipart support.

Security tips

Commands copied from DevTools often contain session cookies and access tokens. The conversion runs entirely in your browser and the command is never sent anywhere or added to the URL, but remember to remove secrets before committing generated code — load them from environment variables instead. Want to try a request right away? Use the API Tester. Need to inspect a token from the command? Paste it into the JWT Decoder.

Também pesquisado como: curl converter, curl to fetch, curl to python, curl to javascript, curl to axios, curl to php, curl to go, curl to node.

Ferramentas que combinam com: cURL to Code

  • Codificação/Decodificação Base64 — Converte texto para Base64 e vice-versa, com suporte total a UTF-8 (acentos, emojis); alterna para Base64 seguro para URLs; ou arrasta um arquivo para obter sua string Base64 ou URI de dados.
  • URL Encode / Decode — Percent-encode text for safe use in URLs, decode encoded strings back to readable text, and break any URL down into its parts and query parameters.
  • Formatação JSON — Cole o JSON aqui para formatá-lo, compactá-lo ou validá-lo.
  • HTTP Header Checker — Fetch any URL and see exactly what the server sends back — status code, redirect chain and every response header, with a plain-English explanation of the ones that matter for SEO, caching and security.

Perguntas frequentes

Is it safe to paste a curl command with my API key or cookies?
The command is parsed in your browser and never sent to our server or stored, and it isn’t added to the page URL. Still treat generated code like any secret-bearing file and move tokens into environment variables.
How do I copy a request as curl from Chrome?
Open DevTools (F12), go to the Network tab, reload the page, right-click the request and choose Copy › Copy as cURL (bash). On Windows, “Copy as cURL (cmd)” also works here.
Why is my -d data sent as form data and not JSON?
That mirrors curl: -d sets Content-Type: application/x-www-form-urlencoded unless you pass your own header. Add -H 'Content-Type: application/json' or use --json and the converter will produce a JSON body.
What happens to file uploads like -F file=@photo.jpg?
They become multipart uploads in every language — FormData in JavaScript, files= in Python, CURLFile in PHP and mime/multipart in Go — referencing the same local path, which you may need to adjust.
Does it follow redirects like curl -L?
fetch, Axios (in Node), Python requests and Go follow redirects by default, while curl only does with -L. In PHP the converter adds CURLOPT_FOLLOWLOCATION when -L is present.
Posso instalar o cURL to Code como um aplicativo da web e usá-lo offline?
Sim. O cURL to Code é um aplicativo da web instalável (PWA) — instalado a partir do seu navegador, não baixado de uma loja de aplicativos. Clique em “Instalar aplicativo” na parte superior desta página no Chrome ou no Edge (Windows, macOS, Linux, ChromeOS) ou, no Android, use “Compartilhar” → “Adicionar à tela inicial” no iPhone e no iPad, ou “Arquivo” → “Adicionar ao Dock” no Safari 17+ em um Mac. Em seguida, ela se abre em uma janela própria com seu próprio ícone e, como é executada inteiramente no seu navegador, continua funcionando offline. O Firefox no desktop não permite a instalação de aplicativos da web. Como funciona a instalação.

Ferramentas relacionadas