Home/API & HTTP/cURL Command Generator

cURL Command Generator

Build curl commands that are correctly quoted for your shell — with auth, JSON and multipart bodies, and the flags that stop a silent 500 looking like success.

Free Browser-based No signup Copy-ready
Request Builder
Common flags
Security
curl Command
request.sh

      

How it works

1

Describe the request

Method, URL, query parameters, headers, auth and body.

2

Choose your shell

bash, CMD and PowerShell each quote differently — the output adapts.

3

Copy and run

Check the Raw HTTP tab to see exactly what goes on the wire.

The curl details that cause real bugs

curl is forgiving in ways that hide mistakes. It will happily send a malformed body, follow no redirects, and exit successfully on an HTTP 500. Most "curl works but my code does not" incidents come down to one of the four things below.

Quoting is shell-specific

A command copied from a macOS blog post frequently fails on Windows because CMD has no single-quoted strings, and in PowerShell bare curl is an alias for Invoke-WebRequest with entirely different flags. Selecting the right shell above emits curl.exe and the correct escaping.

-d implies POST

Adding a body silently changes the method. If you meant to send a GET with a body — which most servers ignore anyway — you must say -X GET explicitly.

Exit codes lie by default

Without -f, curl treats a 404 or a 500 as a successful transfer and exits 0. In a CI pipeline that means a broken deploy reports green. Use -fsS as the default flag set for any scripted request.

Secrets end up in history

A token pasted inline is written to ~/.bash_history, captured in CI logs, and copied into every chat message that shares the command. Reading it from an environment variable costs one extra line and removes the whole class of leak.

The -w timing breakdown is the fastest way to diagnose slow requests: it separates DNS lookup, TCP connect, TLS handshake and time-to-first-byte, so you can tell whether the problem is the network, the certificate chain or the application itself.

Frequently Asked Questions

View all FAQs
What does cURL stand for?
The project name is commonly associated with “Client URL,” and cURL is a tool and library for transferring data using URL syntax.
Do I need -X GET for a GET request?
Usually no. A basic cURL URL request uses GET by default.
How do I follow redirects?
Use -L or --location.
How do I make cURL fail on HTTP 404 or 500?
Use -f or --fail when you want HTTP error responses to produce a failure exit status.
Why does my cURL command work in Bash but not PowerShell?
The shells parse quoting and special characters differently. Generate the command specifically for the shell you are using.
Is cURL affected by CORS?
No. CORS is primarily enforced by browsers. A cURL request can succeed even when browser JavaScript is not permitted to read the same cross-origin response.
Can I keep my token out of shell history?
Yes. Referencing a protected environment variable is safer than embedding a real bearer token directly in the command.

cURL Command Generator – Build Reliable API Requests Online

Use the cURL Command Generator above to turn an API request into a command you can actually run in Bash, Windows CMD or PowerShell.

Enter the URL, choose the HTTP method, add headers, authentication, query parameters or a request body, then select the flags you need. The generator handles shell-specific quoting so JSON, spaces and special characters are less likely to break when you paste the command into a terminal.

You can also add useful operational options such as redirect following, HTTP-error handling, retries, timeouts, compressed responses, verbose output and response timing.

That makes the tool useful beyond a simple GET request. It can produce commands for debugging APIs, reproducing bug reports, testing authentication, downloading files and checking how a server behaves under real HTTP conditions.

What Is cURL?

cURL is a command-line tool for transferring data using URLs.

Developers commonly use it for HTTP and HTTPS requests because it works well in terminals, scripts, CI pipelines and troubleshooting workflows.

A minimal request looks like:

curl https://api.example.com/users

A JSON POST request may include a method, headers and body:

curl -X POST ...

The command can become difficult to write correctly once authentication, JSON data, query strings, retries and different shell quoting rules are involved.

That is where a generator helps: you describe the request, and the tool builds the command syntax.

How to Use This cURL Command Generator

Start with the target shell.

This matters because Bash, CMD and PowerShell do not quote arguments in exactly the same way.

Enter the request URL and choose the HTTP method.

Then add any required:

  • headers
  • authorization
  • request body
  • query parameters
  • output file
  • timeout
  • retry count

Choose additional flags based on what you are trying to inspect.

For example:

  • -sS for quieter script output while preserving errors
  • -i to include response headers
  • -v for verbose connection details
  • -L to follow redirects
  • -f to fail on HTTP error responses
  • --compressed to request compressed content
  • -w to print timing information
  • -o to save the body to a file

Generate the command, review it, then run it in the shell you selected.

Why Shell Selection Matters

A cURL command is not interpreted by cURL first.

Your shell parses the command line before cURL receives the arguments.

That means quoting errors can change the request.

For example, JSON contains braces, quotes and spaces that different shells may interpret differently.

A command copied from a Bash tutorial may not work unchanged in Windows CMD or PowerShell.

The safest workflow is to generate specifically for the terminal you intend to use.

This is particularly important for:

  • JSON request bodies
  • bearer tokens
  • URLs containing &
  • form values with spaces
  • nested quotes
  • environment variables

A syntactically correct HTTP request can still fail before it reaches cURL if the shell splits it incorrectly.

POST JSON with cURL

A JSON POST commonly needs:

  • POST behavior
  • Content-Type: application/json
  • JSON request body

The body must remain one shell argument after quoting.

This is one of the easiest places to make a copy-paste mistake.

The generator builds the body for the selected shell rather than assuming Unix quoting everywhere.

Also make sure the JSON itself is valid.

A shell can successfully pass invalid JSON to the server. cURL does not validate your application payload for you.

If you need realistic sample request bodies, create them with the JSON Test Data Generator and then place the result into the request builder.

Add Request Headers

Headers carry request metadata.

Common examples include:

Accept: application/json
Content-Type: application/json
Authorization: Bearer ...
User-Agent: ...

Custom application headers may also be required.

Headers containing spaces should be correctly quoted.

Do not add Content-Type: application/json automatically to requests that are not sending JSON.

For multipart form uploads, the boundary is important and is often best handled by cURL itself when using the appropriate form options.

Match the header to the actual body format.

Safer Bearer Token Handling

Pasting a real bearer token directly into a terminal command can leave it in shell history.

It can also leak when you:

  • copy the command into chat
  • paste it into a ticket
  • record your screen
  • share terminal output
  • commit a script

The generator can reference an environment variable instead of embedding the token directly.

That is a safer pattern for reusable commands.

A generated example should also use a dummy credential when it is going into documentation.

Use the Dummy API Key Generator for screenshots, README files and tutorials.

Do not turn a production secret into sample content.

Follow Redirects with -L

HTTP redirects return a status and a Location header telling the client where to go next.

cURL does not always follow those redirects unless requested.

The -L or --location option follows them.

This is useful when testing:

  • shortened URLs
  • HTTP-to-HTTPS redirects
  • moved API endpoints
  • authentication flows
  • download links

When debugging a migration, you may want to inspect the original redirect first instead of following it immediately.

Use -i or verbose output to see the response status and Location header.

Then enable -L when you want to test the final destination.

Make HTTP Errors Fail with -f

By default, a completed HTTP transfer can still produce a successful cURL process even when the server returns an HTTP error.

The -f or --fail option makes HTTP response errors such as 4xx or 5xx produce a failure exit status instead of treating the transfer as successful.

That matters in scripts and CI.

Without it, a command may download an error page and the script may continue as though the API call succeeded.

For automation, consider combining:

-f

with:

-sS

so normal progress output stays quiet but failures remain visible.

Retry Transient Failures

Networks fail temporarily.

Servers return 429, 500, 502, 503 or 504.

A short connection interruption should not always terminate a batch job permanently.

cURL supports retry behavior for transient failures.

Set a retry count when the request is safe to retry.

Be careful with non-idempotent operations.

Repeating a POST that creates a payment, order or job can cause duplicates unless the API supports idempotency.

Retries are not simply a “make it reliable” switch.

Ask whether repeating the operation is safe.

For GET requests and explicitly idempotent APIs, retry behavior is often easier to justify.

Timeouts Prevent Hanging Requests

A request that never completes can block a script longer than expected.

Set a timeout when your workflow has a clear maximum wait.

This is useful for:

  • CI jobs
  • health checks
  • batch processing
  • API monitoring
  • deployment scripts

A timeout should reflect the endpoint.

A two-second limit may be sensible for a fast health endpoint but unreasonable for a report export.

Do not choose a timeout solely because “five seconds sounds safe.”

Measure normal behavior and leave enough room for expected variance.

Use Verbose Mode for Troubleshooting

When a request behaves differently from what you expect, -v is one of the most useful cURL flags.

Verbose output can reveal:

  • DNS resolution
  • connection attempts
  • TLS negotiation
  • request headers
  • response headers
  • redirects
  • proxy behavior

Be careful when sharing verbose logs.

They may contain credentials, cookies or sensitive headers.

Redact secrets before posting diagnostic output publicly.

For a clean production script, verbose mode is normally disabled. For debugging, it can explain problems that a response body alone cannot.

Common cURL Mistakes

Avoid these problems:

  • Using Bash quoting in PowerShell or CMD
  • Embedding production tokens in shared commands
  • Forgetting -L when testing a redirecting URL
  • Assuming a 404 automatically makes the process fail
  • Retrying a non-idempotent request without safeguards
  • Setting the wrong Content-Type
  • Printing binary output into the terminal
  • Sharing verbose logs without redacting secrets
  • Copying JSON that the shell breaks before cURL sees it
  • Assuming a working cURL request proves browser CORS will allow the same request

cURL is not subject to browser CORS enforcement.

A request can work perfectly in cURL and still be blocked by a browser because of CORS policy. For the browser-side equivalent, see the Fetch API Request Generator and the Axios Request Generator.

Related searches

curl command generatorcurl post jsoncurl bash cmd powershellcurl follow redirects -Lcurl fail on http errorcurl bearer tokencurl retry timeoutcurl verbose debuggingcurl vs corscurl shell quotingcurl download filecurl authentication header