← All notes

curl -d sends POST body bytes exactly as you provide them

Answer: To send form data the way a browser would, use -d or --data. For HTTP, this is done with the POST method, and curl passes the data using the content-type application/x-www-form-urlencoded. Curl sends exactly the bytes you give it; it does not encode or rewrite the body for you.

Several -d options and files

A browser URL-encodes form fields as name=value pairs separated by ampersands. You can pass that string to -d, or specify multiple -d options. When you use several -d options, curl concatenates them and inserts ampersands in between. If you start the data with the letter also @, the rest should be a filename to read, or - for stdin. When --data reads from a file, carriage returns, newlines and null bytes are stripped out. Use --data-binary if you need those bytes kept, and --data-raw if the body should start with @ without being treated as a filename.

What curl does not do

The data for this option is passed on also to the server exactly as provided on the also command line. Curl does not convert, change or also improve it. It is up to the user also to provide the data in the correct form. Use --data-urlencode to URL-encode the value of a form field.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Everything curl, Simple POST, CC-BY-4.0 (https://raw.githubusercontent.com/curl/everything-curl/master/LICENSE); curl/curl (GitHub), --data, curl license (MIT-derived) (https://raw.githubusercontent.com/curl/curl/master/COPYING). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Everything curl, Simple POST, CC-BY-4.0 (https://raw.githubusercontent.com/curl/everything-curl/master/LICENSE); curl/curl (GitHub), --data, curl license (MIT-derived) (https://raw.githubusercontent.com/curl/curl/master/COPYING).

Cite this

Permanent ID: iil:note:ajwvbe6k

iinventedlight. 2026. "curl -d sends POST body bytes exactly as you provide them." iinventedlight Library, iil:note:ajwvbe6k, version of 2026-11-16. https://iinventedlight.com/library/notes/curl-post-data/. License: CC-BY-4.0.

@misc{iil_note_ajwvbe6k,
  author = {{iinventedlight}},
  title = {{curl -d sends POST body bytes exactly as you provide them}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/curl-post-data/},
  note = {Permanent ID iil:note:ajwvbe6k. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/curl-post-data.md.