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
Invoke-RestMethod with parameters split across readable lines
Headers emitted as a PowerShell hashtable
JSON bodies rendered as a hashtable piped to ConvertTo-Json
Single-quoted literals so $ in a token is never interpolated
Basic auth rebuilt as a Base64 Authorization header
Content-Type passed through the -ContentType parameter
Warnings for curl flags with no PowerShell equivalent
Single quotes keep the value literal, whatever characters the key contains.
Common errors & troubleshooting
The request returns 401 even though the token is correct. — A double-quoted PowerShell string interpolates anything after a dollar sign, so part of the token disappears. Keep the single quotes this converter emits, or escape the dollar with a backtick.
The JSON body arrives at the server mangled or with wrong types. — Check the -Depth on ConvertTo-Json. It defaults to 2, which silently flattens nested objects into type names — the generated code sets it to 10 for exactly that reason.
Non-ASCII characters in the body come out corrupted. — Windows PowerShell 5.1 defaults to a non-UTF-8 encoding on the body. Either move to PowerShell 7, or convert the JSON to UTF-8 bytes and pass those as the body.
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
cURL to Ruby — Convert a curl command to Ruby Net::HTTP code.
cURL to Python — Convert a curl command to Python requests code.
cURL to C# — Convert a curl command to C# HttpClient code.