cURL to PowerShell

Paste a curl command and get a PowerShell script using Invoke-RestMethod, with quoting that will not eat your API token.

cURL to PowerShell converts entirely in your browser. Commands containing tokens or credentials never leave your device.

Open cURL to C#

About cURL to PowerShell

Pasting a curl command into PowerShell rarely works, and not only because the flags differ. PowerShell interpolates variables inside double-quoted strings, so a token containing a dollar sign silently becomes an empty string and the request comes back 401 with no clue why. This converter emits single-quoted literals throughout, which PowerShell treats as raw text, and doubles any internal quote. Headers become a hashtable, a JSON body becomes a hashtable piped through ConvertTo-Json so you can edit it before sending, and basic auth is rebuilt as a Base64 Authorization header — the way it has to be done in PowerShell. The result runs as-is on Windows PowerShell and on PowerShell 7 across platforms.

Features

How to use the cURL to PowerShell

  1. Copy the curl command from the API documentation
  2. Paste it into the left pane
  3. Read the generated PowerShell on the right
  4. Copy it, or download it as a .ps1 file

Example

Input

curl https://api.example.com/users -H "X-Api-Key: abc123"

Output

$headers = @{
    'X-Api-Key' = 'abc123'
}

$response = Invoke-RestMethod `
    -Uri 'https://api.example.com/users' `
    -Method GET `
    -Headers $headers

Single quotes keep the value literal, whatever characters the key contains.

Common errors & troubleshooting

Frequently asked questions

Is curl the same as Invoke-WebRequest in PowerShell?
In Windows PowerShell 5.1, curl is an alias for Invoke-WebRequest, which is why pasting a real curl command fails with confusing parameter errors. PowerShell 7 dropped the alias, so curl there is the real thing if it is installed.
Should I use Invoke-RestMethod or Invoke-WebRequest?
Invoke-RestMethod for APIs — it parses a JSON response into objects you can work with directly. Invoke-WebRequest returns the raw response with status code and headers, which is what you want when those details matter.
How do I send basic authentication in PowerShell?
Base64-encode username:password and pass it as an Authorization header. The -Credential parameter exists but only sends credentials after a challenge, which many APIs never issue.
Why are the parameters split with backticks?
The backtick is PowerShell's line continuation character, so a long call stays readable across several lines. It has to be the last character on the line with no trailing space, which is easy to break when editing by hand.
Will the generated script run on Linux and macOS?
Yes, on PowerShell 7, which is cross-platform. The cmdlets, hashtable syntax and ConvertTo-Json all behave the same way there as on Windows.

Related tools

All ArrayKit tools