About this tool
API docs, bug reports and the browser’s “Copy as cURL” all hand you a curl command, but your test suite needs code. This converter parses the command as a shell would (single and double quotes, $'…' strings, and line continuations from bash, cmd and PowerShell) and turns it into a Playwright test using the request fixture, a REST Assured given/when/then chain, a Python requests call or JavaScript fetch. It keeps the method, URL and query string, headers, Basic auth from -u, JSON, form and raw bodies, and the -k and --max-time options. Options it cannot convert, such as multipart uploads (-F) or client certificates, are listed instead of being silently dropped, so you know what to add by hand. Everything runs in your browser and nothing you paste is sent anywhere.
How to use it
- Paste a curl command into the left panel, or click “Load sample”.
- Pick Playwright, REST Assured, Python requests or fetch. The code updates as you type.
- Copy the code into your test, then replace the example assertions with the ones your test needs. To change the request first, click “Edit in cURL generator”.
Turning the output into a real test
The converted code sends the same request, but a request is not a test until it asserts something. Start with the status (await expect(response).toBeOK() in Playwright, then().statusCode(200) in REST Assured), then assert the fields that prove the behaviour, not the whole body. Ids, timestamps and tokens change between runs, so check their type or format instead of their value.
Move secrets out of the code before you commit it. A command copied from a browser often contains a live session cookie or bearer token: read it from an environment variable or a login fixture instead, and rotate the token if it has been shared.
What “Copy as cURL” adds, and what you can delete
- Browser headers such as sec-ch-ua, sec-fetch-*, user-agent, accept-language and priority. APIs rarely need them, and they make the test harder to read.
- Cookie headers with your session. Replace them with a proper auth step, such as a Playwright storageState or a token request in a fixture.
- Referer and Origin. Keep them only if the API checks them, for example for CSRF protection.
- The Windows variants (“Copy as cURL (cmd)” or “(PowerShell)”) use different quoting, and the converter understands both.
cURL to Code Converter FAQ
How do I convert curl to a Playwright API test?
Paste the command and choose Playwright. The output is a test that uses the built-in request fixture: request.post(url, { headers, data }) followed by expect(response.ok()).toBeTruthy(). Replace that with assertions on the status and the fields your test cares about. It runs with npx playwright test and needs no browser, so it is fast enough for API checks in the same suite as your UI tests.
Which curl options are supported?
-X, -H, -d, --data, --data-raw, --data-binary, --data-urlencode, --json, -u, -G, -I, -i, -L, -k, --compressed, --max-time, -A (user agent), -e (referer) and -b (sent as a Cookie header), plus quoting and line continuations for bash, cmd and PowerShell. Anything else, such as -F multipart uploads or --cert, is listed as a warning so you can add it by hand.
Why does the converted request behave differently from curl?
Usually because of redirects or defaults. curl follows redirects only with -L, while Playwright, REST Assured, Python requests and fetch follow them by default. curl also sends a POST body as form data unless you set Content-Type, so check that header if the API rejects the converted request.
Is my command sent to a server?
No. Parsing and code generation run in your browser, and nothing is uploaded or logged. Still remove tokens and cookies before you paste commands into shared bug reports or code.