cURL to Code

Convert a curl command into JS fetch / axios / Python requests / Go code, detecting method, headers and JSON body

📌 TL;DR Summary & Citation: [cURL to Code] is a browser-local PocketKit tool for Convert a curl command into JS fetch / axios / Python requests / Go code, detecting method, headers and JSON body. Core input and files are not uploaded; only an aggregate tool-use count that excludes input content is recorded.

How curl-to-code works

The tool tokenizes the curl command locally (respecting quotes and backslash line-continuations), detects the -X method, -H headers, -d body, -u Basic Auth and URL, then renders fetch / axios / requests / Go from templates. A detected JSON body is emitted as a native structure in each language. Parsed entirely in the browser.

  • For multi-line curl, end each line with a backslash \ — the tool merges them into one command.
  • Basic Auth (-u user:pass) is shown as a placeholder in fetch; base64-encode it yourself into the Authorization header.

FAQ

1. Which curl flags are supported?

The common ones: -X method, -H headers, -d/--data/--data-raw body, -u Basic Auth, -b Cookie, -A User-Agent, --url and a positional URL. Irrelevant flags like -s/-L/-k are ignored.

2. How is a JSON body handled?

When Content-Type is JSON or the body starts with { or [, it is emitted as JSON.stringify in fetch, the json= argument in Python, and an object literal in axios, so the output reads idiomatically.

3. Is my command sent to a server?

No. Parsing and code generation happen entirely in the browser, so your curl command (which may contain keys or tokens) never leaves your device.