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.

Built and maintained by Udit Agarwal

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

  • 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
  • Download the result as a .ps1 file
  • Conversion runs entirely in your browser

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

  • 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

Guides

More API Tools tools

  • cURL to Swift — Turn a curl command into Swift code that uses URLSession.
  • cURL to Dart — Turn a curl command into Dart code for Flutter using package:http.
  • cURL to Fetch — Convert a curl command to a JavaScript fetch() call.
  • URL Parser — Break a URL into its parts and list query parameters.
  • API Request Client — Send HTTP requests, build headers and params, inspect responses — your last 25 requests are saved locally.
  • URL Builder & UTM Generator — Construct and validate fully encoded production URLs with standard analytics query flags (UTM) or custom query arrays.
  • OpenAI API Tester — Build, run and copy OpenAI Chat Completions API requests as cURL, Python and JavaScript.
  • Anthropic Claude API Tester — Build, run and copy Anthropic Claude Messages API requests as cURL, Python and JavaScript.
  • Google Gemini API Tester — Build, run and copy Google Gemini generateContent API requests as cURL, Python and JavaScript.
  • Replicate API Tester — Build, run and copy Replicate prediction API requests as cURL, Python and JavaScript.
  • Hugging Face API Tester — Build, run and copy Hugging Face Inference API requests as cURL, Python and JavaScript.
  • cURL to Python — Convert a curl command to Python requests code.

See all API Tools tools (24) · All tools