curl vs HTTPie isn’t a choice I make once: I use these tools interchangeably. Giving the command to an AI agent adds a requirement, though: a failed HTTP request needs to look like a failure to the process running it.
The short version: use the client that makes the current job easiest to express, then make its scripting behavior explicit. Readable JSON input, useful error output and a reliable download matter more than choosing one client for everything.
I recently refreshed my Wget guide, and I want to connect that advice to how I use HTTP tools today. This is my view of an interchangeable toolkit, with local checks of the defaults that matter when an agent runs the commands.
curl vs HTTPie starts with the request
HTTPie earns its place when you want to see the shape of a request before sending it. Its request-item syntax turns fields into JSON, and --offline constructs the request without contacting the server.1
Previewing the JSON before an agent sends it
Here’s a safe request preview using HTTPie’s http command. The example domain is deliberate: offline mode sends nothing there.
http --offline --ignore-stdin POST https://example.com/items \
message=hello count:=2
message=hello creates a string; count:=2 creates a JSON number. The distinction matters if the API validates types. The request body is {"message": "hello", "count": 2}, with a JSON content type.1
This is a useful place to review a proposed write. Check the method, URL, field names and value types before letting an agent send it. An offline preview can’t tell you whether authentication will work or whether the server will accept the data. Don’t put a real credential into a preview that will be copied into a transcript.
xh looks familiar, but check its defaults
xh uses HTTPie’s request-item syntax and supports offline construction too. It’s mostly compatible with HTTPie, so a familiar command line is a starting point for checking compatibility.2
One difference is directly relevant to agents: xh normally checks HTTP status by default. HTTPie needs --check-status for that scripting policy. xh’s HTTPie compatibility mode changes its default, which is another reason to spell the flag out in a shared command.1,2
That makes xh an alternative worth considering when you like this syntax. There are no startup-time or token-usage measurements behind this comparison.
Compare the behavior an agent depends on
The table compares ordinary HTTP requests with clean configuration, not download modes or customized defaults. The curl column follows its manual, HTTPie its CLI documentation, and xh its version 0.26.3 manual.3,1,2
| Task or behavior | curl | HTTPie (http) | xh |
|---|---|---|---|
| Useful starting point | Existing scripts, raw payloads and transfer controls | Building and inspecting API requests | HTTPie-style requests with status checking enabled |
| Build a JSON body | --json sends supplied JSON; it doesn’t validate it | name=value for strings, count:=2 for numbers | Same basic request-item syntax as HTTPie |
| Preview without sending | No direct equivalent to --offline | --offline | --offline; --curl prints a curl translation |
| Default exit on an HTTP 404 | 0 if the transfer succeeds | 0 if the transfer succeeds | 4 in normal mode; compatibility mode differs |
| Fail on 4xx/5xx and keep the body | --fail-with-body, exit 22 | --check-status, exit 4/5 | Explicit --check-status, exit 4/5 |
| Follow redirects | Opt in with -L | Opt in with --follow | Opt in with --follow |
| Read a request body from stdin | Explicit, for example --data-binary @- | Automatic with redirected input; use --ignore-stdin when unwanted | Same precaution as HTTPie |
| Output for a JSON parser | Response body by default; -sS keeps progress out of diagnostics | Piped output defaults to unformatted body; --body --pretty=none makes intent explicit | Piped output defaults to unformatted body; --body --pretty=none makes intent explicit |
Use curl when the payload is already prepared or you need its transfer options. With HTTPie, request-item syntax makes small typed JSON requests easy to read before sending; xh offers similar syntax with a different status-checking default. Those are reasons to switch tools for a job, rather than declare one the winner.
curl’s --json shortcut has been available since 7.82.0. It combines binary body handling with JSON Content-Type and Accept headers, so readable JSON requests aren’t exclusive to HTTPie. For complicated bodies, a reviewed payload file can be clearer than either client’s inline arguments.3
A 404 must reach the agent as a failure
A local fixture check on November 10, 2026 returned the same JSON error with HTTP 404 to each client. With no explicit HTTP-failure option, curl and HTTPie exited successfully. Normal-mode xh and GNU Wget returned nonzero exit codes.
The versions were curl 8.7.1, HTTPie 3.2.4, xh 0.26.3 and GNU Wget 1.25.0. These were isolated loopback HTTP checks, with output captured through pipes. The disposable Wget build had HTTPS disabled, so its results say nothing about TLS behavior.
Keep the error body and the exit code
For a read-only request, these are useful starting forms. Set URL to your endpoint, then run whichever installed client you want to use:
curl -sS --fail-with-body --max-time 10 "$URL"
http --ignore-stdin --check-status --timeout=10 GET "$URL"
xh --ignore-stdin --check-status --timeout=10 GET "$URL"
curl’s -sS removes the progress meter while retaining error messages. --fail-with-body preserves an HTTP error response body and returns error 22 for HTTP status 400 or greater.3 HTTPie’s and xh’s checked 4xx responses return exit code 4.1,2
For the local 404 fixture, the explicit forms above produced:
curl: exit 22, JSON error body retained
HTTPie: exit 4, JSON error body retained
xh: exit 4, JSON error body retained
The exit code lets a runner reject the operation; the body can explain why it failed. It still needs to check that a successful response has the expected content. HTTP 200 carrying an HTML login page won’t become valid JSON because the process exited zero.
Stdin, timeouts and redirects need separate decisions
--ignore-stdin is intentional in the GET examples. HTTPie can read redirected stdin as a request body, which is usually unwanted in a noninteractive invocation. Remove that flag when piping a body deliberately.1 xh documents the same scripting precaution.2
The timeout flags above aren’t equivalent deadlines. curl’s --max-time limits each transfer.3 Put an outer process deadline around an agent job when its entire runtime must be bounded.
Redirects also differ. In the local checked 302 case, curl returned zero without following, HTTPie and xh returned 3, and Wget followed automatically. curl’s -L and HTTPie’s or xh’s --follow opt into following.3,1,2 Review the destination and method behavior before enabling redirects on a write.
Choose what the next step needs to receive
The terminal display and piped output in HTTPie have different defaults: redirected output normally contains the unformatted response body without terminal colors.1 Choose the output for its consumer. A person inspecting headers and a JSON parser need different things.
For a JSON file sent with curl, --data-binary @payload.json with a JSON content-type header preserves the file bytes. --data @payload.json strips carriage returns, newlines and NUL bytes.3 Similar-looking body options deserve a check before switching clients.
Credential handling deserves the same care. A different HTTP client doesn’t keep secrets out of command history, logs or agent transcripts automatically. My agent credential setup covers passing secrets to the program without handing their values to the agent.
If you’re weighing curl vs HTTPie for your own agent:
- Preview a write with dummy values before sending it.
- Make HTTP failures visible and preserve useful diagnostics.
- Decide how stdin, redirects and execution time should behave.
- Validate the returned data or downloaded file before using it.
