Httpie: what it is, an HTTP client for the command line

Author: IT Sectr Published: 2026-05-08 Reading time: 8 min

Httpie is a command-line HTTP client with human-readable syntax and colored output, designed for testing APIs from the terminal. The tool uses intuitive syntax: http GET https://api.example.com/users without the need to specify flags for headers and the request body. According to Httpie CLI Documentation (2026), the utility supports JSON by default, sessions, authentication, and plugins.

Key Points

  • Httpie is a modern replacement for cURL with readable syntax, colored highlighting, and built-in JSON serialization.
  • Syntax of a request follows the scheme: http [method] URL [header:value] [key=value] without additional flags.
  • JSON by default — the request body is treated as a JSON object, and the Content-Type header is set automatically.
  • Sessions preserve cookies and headers between requests, which is convenient for testing authenticated endpoints.
  • Plugins extend Httpie with support for additional formats, authentication types, and custom transports.

What is Httpie and how is it different from cURL

Httpie (or HTTPie) is a command-line utility written in Python that simplifies sending HTTP requests compared to cURL. The main difference is syntax close to natural language: arguments are separated by spaces, headers are specified with a colon, and JSON data is specified with an equals sign without escaping quotes.

Comparison of cURL and Httpie

The same POST request in cURL requires at least three flags (-X, -H, -d) and manual JSON escaping. Httpie does the same in three words without flags, automatically setting Content-Type: application/json and highlighting the output. The response is formatted with indentation and syntax highlighting by default.

OperationcURLHttpie
GET requestcurl https://api.example.comhttp GET https://api.example.com
POST JSONcurl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' https://api.example.comhttp POST https://api.example.com name=test
Headercurl -H "Authorization: Bearer token123" https://api.example.comhttp GET https://api.example.com Authorization:"Bearer token123"

Httpie request syntax

Httpie uses a single command-line format without flags for the main parameters. The HTTP method is specified as the first argument (GET, POST, PUT, DELETE, PATCH), the URL as the second. If the method is omitted, Httpie automatically chooses GET (for requests without a body) or POST (with a body).

Argument types

  • Header:Value — request headers with a colon, no space after the colon: Authorization:"Bearer token".
  • key=value — JSON object fields in the request body: name=John age=30.
  • key:=value — non-string JSON values (numbers, booleans, arrays): active:=true tags:=["dev","test"].
  • key@file — loading a value from a file: avatar@~/photo.jpg.

Httpie automatically determines the data type: if key=value is passed, the body is sent as JSON. If raw text is passed via --raw, it is sent as plain text. The form-data format is activated with the -f flag.

bash
# POST request with JSON data and a header
http POST https://api.example.com/users \
    name="John Doe" \
    email="john@example.com" \
    role:="admin" \
    Authorization:"Bearer test123"

# Response with highlighting and pretty-print
HTTP/1.1 201 Created
Content-Type: application/json
{
    "id": 42,
    "name": "John Doe"
}

Working with JSON and files

JSON serialization in Httpie works automatically: a value passed as key=value becomes a string field of the JSON. For numbers and boolean values, key:=value is used. Nested objects are created using dot notation: address.city=Moscow.

Uploading files and binary data

Httpie supports the multipart/form-data format for uploading files and data via the key@path syntax. If you need to send the file contents as the raw request body, input redirection is used: http POST example.com < file.json. To download the response to a file, the -d (download) flag is used.

bash
# Sending JSON from a file
http POST https://api.example.com/users < user.json

# Uploading a file via multipart
http -f POST https://api.example.com/upload \
    photo@~/photo.jpg \
    description="Profile photo"

Managing sessions and cookies

Sessions in Httpie preserve state between requests: cookies, headers, and authentication parameters. A session is created with the --session=name flag. Session data is stored in a JSON file in the ~/.httpie/sessions/ folder. A session with the :readonly suffix is not updated after a request.

Session testing example

First, a POST request to /auth/login is made with credentials — the server returns a session cookie. All subsequent requests to protected endpoints within the same session automatically send the saved cookie, which simulates browser behavior when testing the API of a mobile app.

bash
# Step 1: authentication
http --session=app-test POST https://api.example.com/auth/login \
    username="dev" password="secret"

# Step 2: request with the saved session cookie
http --session=app-test GET https://api.example.com/users/me

Authentication and headers

Httpie supports all the main authentication types via flags: -a user:pass for Basic Auth, --auth-type=digest for Digest, --auth-type=bearer TOKEN for Bearer Token. Custom headers are added as HeaderName:value anywhere in the command.

OAuth 2.0 and Bearer Token

For testing an API with OAuth 2.0, the token is passed via the Authorization header. Httpie does not manage the token lifecycle at the core level — an external script does this. The command http --auth-type=bearer --auth="$TOKEN" GET https://api.example.com/resource is equivalent to explicitly specifying the header with the token.

Using Httpie in CI/CD scripts

Httpie is ideal for CI/CD pipelines thanks to zero dependencies (except Python) and readable output. Commands are easy to read in logs without additional parsing. The tool is installed via pip and is available in all popular Docker images, including Alpine, Ubuntu, and the official CI images of Jenkins and GitLab. This makes Httpie a convenient choice for automated testing of REST APIs and microservices.

Checking the health endpoint during deployment

A typical scenario is checking the API status after deploying an application. Httpie sends a request to the health endpoint and exits with a non-zero code if the response does not match the expected one. The --check-status flag automatically returns an error for status codes >= 300.

bash
# Health check in the deploy script
http --check-status GET https://api.staging.example.com/health
    status:="ok" && \
    echo "API is healthy" || \
    echo "API check failed"

Advanced Httpie features and plugins

Httpie supports plugins through the Package Index system. Plugins add new authentication types, serialization formats, and transports. Installation is done via pip: pip install httpie-plugin-name. After installation, the plugin is automatically activated at the next Httpie launch.

Popular Httpie plugins

  • httpie-jwt-auth — automatic retrieval and refresh of JWT tokens via the refresh token mechanism.
  • httpie-oauth — support for OAuth 2.0 Client Credentials and Authorization Code flow with automatic code exchange for a token.
  • httpie-editor — opens the request body in a text editor (vim, nano, VS Code) before sending.
  • httpie-image — displays images from the response directly in the terminal (requires kitty or iTerm2).

Scripting and output parsing

Httpie supports jq-like filtering via the --pretty=format option and cURL-compatible output via --print. The --quiet flag disables colored output for better readability in CI logs. For programmatic response processing, use the --body flag, which outputs only the response body without headers.

bash
# Extracting a field from a JSON response with jq
http GET https://api.example.com/users/1 | jq '.name'

# Output only the response body (without headers)
http --body GET https://api.example.com/health

# Batch sending with different data from a file
while read -r line; do
    http POST https://api.example.com/items $line
done < items.txt

Output formats and customization

Httpie supports output formats via the --print flag: H (request headers), B (request body), h (response headers), b (response body). The --print=hb combination outputs only the response headers and body. The --pretty=all flag enables colored formatting with indentation.

Custom color schemes

Httpie supports customization via the HTTPIE_COLORS variable. Configure colors for URL, headers, JSON, and status codes. Built-in themes are available: autumn, borland, fruity, monokai, native, tango for different terminals.

Output in JSON format

For programmatic processing, use --body --pretty=none, which returns raw JSON. Compact output is useful for passing to jq, sed, and other parsers when automating API testing in scripts.

Output formats and appearance customization

Httpie supports several output formats via the --print flag: H (request headers), B (request body), h (response headers), b (response body). The --print=hb combination outputs only the response headers and body, excluding connection meta-information. The --pretty=all flag enables colored formatting with indentation for readability.

Custom color schemes

Httpie supports color customization via the HTTPIE_COLORS environment variable. You can configure colors for URL, headers, JSON keys, and response status codes. Built-in themes are available: autumn, borland, fruity, monokai, native, and tango for different terminal types and personal preferences.

Output in JSON format without formatting

For programmatic output processing, use the --body --pretty=none flag combination, which returns raw JSON without colors and indentation. Compact output is useful for passing to jq, sed, and other console parsers when automating REST API testing in shell scripts.

Frequently Asked Questions

What makes Httpie better than standard cURL?

Httpie offers more readable syntax without flags for basic operations, automatic JSON serialization, colored response highlighting, and built-in session support. cURL remains indispensable for low-level operations: working with FTP, SMTP, and non-standard protocols.

How do I send form-data via Httpie?

Use the -f flag (or --form): http -f POST example.com name=John file@~/photo.jpg. Httpie will automatically set Content-Type: multipart/form-data. Without the -f flag, data is sent as application/json.

Does Httpie support HTTPS and certificates?

Yes, Httpie supports HTTPS. For self-signed certificates, use the --verify=no flag. To specify a custom CA file: --verify=/path/to/cert.pem. Certificate verification is enabled by default.

Can Httpie be used for WebSocket?

No, Httpie does not support WebSocket and is intended exclusively for the HTTP/HTTPS protocol. For WebSocket, use websocat or wscat. Httpie focuses on REST, GraphQL, and file operations.

How do I save a response to a file via Httpie?

Use the -d (download) flag: http -d GET https://example.com/file.zip. Httpie will save the file with the original name from the Content-Disposition header or URL. For a custom name, specify -o output.zip.

Summary

  • Httpie — a command-line HTTP client with intuitive syntax, JSON by default, and colored output.
  • Basic syntax http [method] URL [key=value] [Header:value] requires no flags for most requests.
  • JSON serialization is automatic: key=value becomes a JSON field, key:=value for numbers and boolean values.
  • Sessions preserve cookies and headers between requests for testing authenticated endpoints.
  • Authentication supports Basic, Digest, Bearer, and custom schemes via the --auth-type flag.
  • CI/CD integration with --check-status and zero dependencies makes Httpie convenient for deployment scripts.
  • File uploads via multipart form-data with the -f flag and key@file syntax.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also