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
- id: C1 claim: Use -d or --data to send form data as a POST body. source: S1 evidence: "To send form data, a browser URL encodes it as a series of"
- id: C2 claim: curl sends the body bytes exactly as you provide them. source: S1 evidence: "curl sends exactly the bytes you give it"
- id: C3 claim: For HTTP, --data uses POST like a browser submitting a form. source: S2 evidence: "this is done with the POST method in the same way that a browser"
- id: C4 claim: A leading @ tells --data to read the body from a filename. source: S2 evidence: "If you start the data with the letter @, the rest should be a filename"
Sources
- [S1] Simple POST. Everything curl. https://everything.curl.dev/http/post/simple.html . License: CC-BY-4.0. Accessed 2026-11-16.
- [S2] --data. curl/curl (GitHub). https://github.com/curl/curl/blob/master/docs/cmdline-opts/data.md . License: curl license (MIT-derived). Accessed 2026-11-16.
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
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.},
}
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.