How to Format a Long cURL Command

By Ramanathan Aug 11, 2026 1 min read cURL Formatter

Copy a request as cURL from your browser's dev tools and you get one enormous line. Formatting it across multiple lines makes it readable, reviewable, and easy to drop into a script or a README.

The readable multi-line form

A formatted curl command puts each option on its own line, joined with a backslash:

curl 'https://api.example.com/users' \
  -X POST \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer xyz' \
  -d '{"name":"Ada"}'

The trailing \ is a line continuation — the shell treats all those lines as one command. It runs exactly the same as the single-line version, just far easier to read and diff.

How quoting works

Quoting matters when values contain spaces or special characters:

  • Single quotes ('...') are safest — the shell treats everything inside literally, so a JSON body or a header with spaces stays intact.
  • Values without spaces or special characters — like POST or a simple URL — don't need quotes.
  • A URL with a query string (?page=2&sort=asc) should be quoted, because & otherwise tells the shell to run the command in the background.

Watch the ampersand

That last point is the most common footgun: an unquoted & in a URL splits the command. Formatting a command and quoting the URL fixes it in one step.

Related

Part of The Complete Guide to HTTP. Testing an API? Look up the HTTP status code you get back, or parse the response headers.

Try it

Paste a curl command and get a clean, multi-line version instantly — everything runs in your browser, nothing uploaded.

About the author

Ramanathan · Software Engineer & Solutions Architect

I'm a Software Engineer and Solutions Architect with 20+ years of experience building enterprise applications across BFSI, Healthcare, Retail, Manufacturing, and Industrial Automation. I've spent those two decades living in JSON, tokens, regexes, and config files — so I built the fast, private, no-login developer tools I always wanted to reach for myself.

Last updated: Aug 11, 2026