API Toolkit

cURL Converter

All tools

Paste a curl command and get a fetch() starting point for your JavaScript.

How it works

Four simple steps

1

Paste the command

Multi-line commands with backslashes are fine.

2

Flags are read

Method, -H headers and -d body are extracted.

3

Review the fetch code

Check the URL and body lines against the original.

4

Copy or save

Copy the snippet or download request.js.

cURL Converter

About cURL Converter

The API documentation only gives curl examples, and you need the same request inside a React app. Translating flags into fetch options by hand is fiddly, so paste the command and start from generated code instead.

The converter reads the method from -X or --request (defaulting to GET), headers from each -H flag, and the body from -d, --data, --data-raw or --data-binary. Backslash line continuations are joined first, so multi-line commands copied from documentation work. The output is a fetch() call with method, a headers object and a body when one was found, followed by a .then chain that logs the response text. When the command has no headers, an Accept: application/json header is added as a placeholder. Copy the code or download it as request.js.

The parser is deliberately simple, so compare the output with the original before using it. It finds the URL reliably when the URL is wrapped in quotes; with an unquoted URL followed by quoted headers, it can pick up a header as the URL. Bodies are read up to the first quote character, so a JSON body in single quotes is cut off at its first double quote, and you should paste JSON bodies into the generated code yourself. Long-form --header, -u, -F, -b and --json are not recognized, and -d without -X stays GET. To try the request from the browser, the API tester accepts the same method, headers and body, and the JavaScript formatter tidies the result.

Conversion is text processing inside this page. The command is never executed and the URL is never contacted.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

No. The only output is JavaScript using fetch(), which runs in browsers and in Node.js 18 and later.

The URL was not quoted, and the parser picked up the first quoted value in the command instead. Wrap the URL in single or double quotes and the correct address is used.

No. Add an Authorization header yourself containing the word Basic followed by the Base64 encoding of user:password.

View more FAQs

Related tools

View all

Webhook HMAC Signer

Sign and verify GitHub, Stripe, and Slack webhook signatures locally.

Open

Webhook Replay Diff Lab

Compare webhook payload timelines, re-check HMAC digests, and spot idempotency gaps locally.

Open

JSONPath Playground

Query JSON with JSONPath and JMESPath-style paths side by side.

Open

GraphQL Studio

Format, validate, and cost-estimate GraphQL documents with cURL export.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools