While curl is the undisputed foundation of internet data transfer across UNIX platforms, constructing complex JSON payloads, inspecting HTTP headers, and debugging RESTful APIs using raw curl flags often requires tedious escaping and verbose parameters. In response, modern developers created HTTPie for friendlier human-centric syntax, but its Python interpreter dependency introduces noticeable startup lag.
xh is a fast, friendly, and modern tool for sending HTTP requests, built completely in Rust. Featuring native HTTPie-compatible syntax, instantaneous startup latency, automatic JSON handling, syntax-highlighted responses, and built-in TLS session caching, xh is the ideal HTTP tool for developers and sysadmins. Here is how to install and master xh on Linux.
Why Choose xh Over curl and HTTPie?
xh blends the best attributes of modern and legacy networking tools:
- Native Speed: Compiled directly to a static Rust binary with near-zero startup overhead, making it significantly faster than Python-based HTTPie.
- Automatic JSON Formatting: Automatically sets
Content-Type: application/jsonand formats key-value inputs into valid JSON objects without typing quotation marks. - Rich Terminal Output: Delivers colour-coded HTTP headers, highlighted JSON syntax, and formatted response times out of the box.
- cURL Command Export: Use the
--print=cflag to convert any interactive xh command into an equivalentcurlcommand for documentation or shell scripts.
Installing xh on Linux Distributions
xh is packaged across major repositories and as pre-compiled standalone binaries.
Method 1: Universal Pre-Compiled Binary
To acquire the latest official static release directly from GitHub:
curl -LO https://github.com/ducaale/xh/releases/latest/download/xh-v0.22.2-x86_64-unknown-linux-musl.tar.gz
tar -xvf xh-v0.22.2-x86_64-unknown-linux-musl.tar.gz
sudo install xh-v0.22.2-x86_64-unknown-linux-musl/xh /usr/local/bin/
xh --version
Method 2: Arch Linux and Fedora
On Arch Linux:
sudo pacman -S xh
On Fedora Linux:
sudo dnf install xh -y
Method 3: Debian / Ubuntu (via Cargo or Homebrew)
If you have Cargo installed:
cargo install --locked xh
Or via Homebrew on Linux:
brew install xh
Sending Basic GET Requests
To perform a simple HTTP GET request, execute xh followed by the target URL:
xh httpbin.org/get
xh automatically prefixes https:// if the protocol is omitted, connects to the server, and prints the formatted HTTP status code, headers, and syntax-highlighted JSON body.
Sending JSON POST Requests
Unlike curl, which requires typing -X POST -H "Content-Type: application/json" -d '{"name":"John"}', xh uses intuitive key-value assignments:
xh POST httpbin.org/post name="John Doe" role="Engineer" age:=30 active:=true
Notice the syntax distinctions:
=(string value):name="John Doe"maps to"name": "John Doe".:=(raw JSON type):age:=30andactive:=truepreserve integer numbers and booleans rather than converting them to strings.
| Item Syntax | Type | Output Result |
|---|---|---|
key=value |
String Data Field | JSON string: "key": "value" |
key:=value |
Raw JSON Value | Number/Boolean: "key": 100 |
Header:Value |
HTTP Request Header | Authorization: Bearer xyz |
param==value |
URL Query Parameter | Appends ?param=value to URL |
Adding Authentication and Bearer Tokens
To pass authentication credentials cleanly:
xh httpbin.org/bearer -A bearer -a "secret_token_123"
For standard HTTP Basic Authentication:
xh httpbin.org/basic-auth/user/pass -a user:pass
Downloading Files with Resume Support
To download a file while preserving its remote filename and displaying a progress bar, use the --download (or -d) flag:
xh -d https://example.com/archive.tar.gz
To resume an interrupted download, add the -c (continue) flag:
xh -d -c https://example.com/archive.tar.gz