cURL to PowerShell
Convert a curl command to PowerShell Invoke-RestMethod
About cURL to PowerShell
Rewrites a bash-style cURL command as a PowerShell Invoke-RestMethod call, with -Uri, -Method, -Headers and -Body on backtick-continued lines. Headers and -F fields become hashtables, strings are single-quoted so $ signs are not expanded, and the parsed JSON response is printed with ConvertTo-Json -Depth 10. The conversion runs in your browser; nothing is uploaded.
Category: API.
Frequently asked questions
Why does the output use Invoke-RestMethod instead of Invoke-WebRequest?
▾
Invoke-RestMethod parses a JSON response into PowerShell objects directly, so the script only has to print it with $response | ConvertTo-Json -Depth 10. The parameters it uses, -Uri, -Method, -Headers and -Body, exist in both Windows PowerShell 5.1 and PowerShell 7.
How does the PowerShell script send -F form fields and -u credentials?
▾
-F fields become a hashtable passed to -Body, which Invoke-RestMethod sends as a URL-encoded form on POST rather than multipart; PowerShell 6.1 and later offer -Form for that. -u user:pass becomes an Authorization: Basic entry in $headers instead of -Credential.
Can I paste a command that uses PowerShell or cmd line continuations?
▾
Paste the bash-style version instead: backslash line breaks and single, double or $'...' quotes are understood, but a trailing backtick or ^ is read as an extra argument and can replace the URL. In Windows PowerShell 5.1, curl is an alias of Invoke-WebRequest, so run curl.exe to test the original command.
Which PowerShell parameters replace -k, -A, -b and --max-time?
▾
None are added automatically. Use -SkipCertificateCheck (PowerShell 6 and later) for -k, -UserAgent for -A, -TimeoutSec for --max-time and a Cookie entry in $headers for -b; redirects need nothing, as Invoke-RestMethod follows them by default.