About this tool

The cURL to Code converter parses a curl command — including headers, method, body, and basic auth — and generates equivalent, ready-to-run code in JavaScript (fetch), Node.js (axios), Python (requests), PHP (cURL), or Go (net/http). cURL is still the default way API documentation shows example requests, but translating that into the language you're actually working in is tedious and error-prone by hand — especially with multiple headers and a JSON body. This tool does the translation instantly.

When to use it

  • Converting a curl example from API documentation into the language your project actually uses
  • Turning a request copied from browser DevTools ('Copy as cURL') into a script for testing or automation
  • Quickly prototyping an API call in Python or Go without hand-translating headers and body syntax
  • Sharing a runnable code snippet with a teammate who doesn't want to run a raw curl command

Tips

  • Paste multi-line curl commands (with trailing backslashes) copied directly from a terminal or browser DevTools — they're handled automatically.
  • Basic auth (-u user:pass) is converted into an Authorization: Basic header automatically, matching what curl does under the hood.
  • Switch the language tab after pasting once — the same parsed command regenerates instantly in every supported language.
  • From the HTTP Request Builder, use 'Copy as cURL' then 'Convert to another language' to deep-link a request you built visually straight into this tool.

Frequently asked questions

Does this tool actually execute the curl command?

No — it only parses the command's text (method, URL, headers, body) and generates equivalent source code. Nothing is sent over the network. This makes it safe to paste commands containing real tokens or credentials, since nothing leaves your browser either during parsing or in the generated code.

What curl flags are supported?

The parser handles -X/--request, -H/--header, -d/--data (and its variants), -u/--user (basic auth), -b/--cookie, --url, -A/--user-agent, and common no-argument flags like -k, -s, -L, and --compressed (safely ignored since they don't affect the generated code's request semantics). Multipart form uploads (-F) and more exotic flags aren't currently translated.

Why does the generated Authorization header show a Base64 string instead of my username and password?

That's exactly what curl -u user:pass does internally — HTTP Basic Authentication sends credentials as Base64-encoded text in the Authorization header, not encrypted. The generated code reproduces the same header curl itself would send. Note that Base64 is trivially reversible, so Basic Auth should only ever be used over HTTPS.

Can I convert code back into a curl command?

Not with this tool directly, but the HTTP Request Builder's 'Copy as cURL' button does the reverse — build a request visually with the method, URL, headers, and body fields, and it generates the equivalent curl command for you.

Related tools

🥷 ToolNinja