Overview
Convert a cURL command into ready-to-run fetch code, and into typed OpenAI or Anthropic SDK calls when the URL matches those APIs. Paste the command, read the JavaScript, copy it. Parsing and code generation happen entirely in your browser, and the generated SDK snippets keep your API key as an environment variable rather than a literal.
How It Works
Paste a cURL command into the editor. The tool extracts the URL, the HTTP method, every -H header and the --data or --data-raw body, then renders a fetch snippet with the method, headers and a JSON-stringified body, plus a status check that throws on non-OK responses. If the URL contains api.openai.com or api.anthropic.com, a second block appears with the equivalent OpenAI or Anthropic SDK call, reading the key from the environment by default. Unparseable input gets a specific error, such as a missing URL, rather than wrong code.
Step-by-Step Usage Guide
- Paste the cURL command, including its headers and data.
- Read the generated fetch snippet and check the method and headers.
- If the URL is an OpenAI or Anthropic endpoint, read the SDK equivalent too.
- Copy the snippet and replace the environment key reference in your project.
Technical Specifications & Standards
The parser is a set of regular expressions rather than a full shell tokenizer, which keeps the tool light but defines its limits: it finds the first http or https URL, reads -X for the method (defaulting to GET, or POST when --data is present), collects quoted -H 'Name: value' pairs, and takes the body from a single-quoted or double-quoted --data or --data-raw argument. Flags it does not know - multipart -F uploads, cookie jars, compression options - are ignored rather than approximated, so review the output before trusting it for anything beyond a simple JSON POST. The fetch snippet deliberately stringifies the body, because cURL's --data sends raw text while fetch expects a string, and JSON APIs expect JSON. SDK generation keys off the hostname: OpenAI commands become client.chat.completions.create with the model and messages from your body; Anthropic commands become client.messages.create with max_tokens preserved. Keys are emitted as environment references, never interpolated, which is the safe default.
Targeted Use Cases
- Turning a cURL example from API docs into code for a JavaScript project.
- Migrating a quick terminal test of an LLM endpoint into application code.
- Learning what headers an OpenAI or Anthropic request actually needs.
- Sharing a reproducible fetch snippet in a code review instead of a shell command.
Notes & Gotchas
- Check the generated headers - the parser only takes quoted -H pairs.
- Keep keys in environment variables; the output already assumes that, so do not paste a key into it.
- For multipart uploads or cookie handling, convert manually - those flags are out of scope.
- Verify the JSON body survived quoting, especially if your cURL used escaped quotes.
Frequently Asked Questions
Which cURL flags are supported?
The URL, -X method, -H headers, and --data or --data-raw bodies. Other flags such as -F multipart uploads or -b cookies are ignored rather than guessed.
How does the SDK generation decide between OpenAI and Anthropic?
By hostname. URLs containing api.openai.com generate OpenAI SDK code, and api.anthropic.com generates Anthropic SDK code. Other hosts only produce the fetch snippet.
Where does my API key go in the output?
Nowhere. The generated code reads the key from an environment variable, and the page reminds you never to hardcode it.
Why is the body wrapped in JSON.stringify?
cURL sends --data as raw text, while fetch expects a string for the body option. Stringifying the parsed JSON keeps the payload byte-faithful and syntactically valid.