# xh — Friendly and Fast HTTPie-Compatible HTTP Client in Rust > xh is a blazing-fast HTTP client with an HTTPie-compatible UX, written in Rust, shipping as a single static binary with built-in JSON syntax highlighting, forms, sessions, and HTTP/2. ## Install Save in your project root: # xh — Friendly and Fast HTTPie-Compatible HTTP Client in Rust ## Quick Use ```bash brew install xh # GET with pretty JSON xh httpbin.org/json # POST JSON body + header xh POST api.example.com/users name=alice role=admin Authorization:"Bearer $TOKEN" ``` ## Introduction `xh` gives you HTTPie's human-friendly syntax at Rust-level speed and portability. It's a single binary you can drop into Alpine containers and CI runners without pulling in Python. For teams that love HTTPie's `key=value` body shorthand and colorized JSON but resent the cold-start cost, xh is a near drop-in replacement. ## What xh Does - Performs HTTP/1.1, HTTP/2, and HTTPS requests from the command line. - Offers HTTPie-style shorthand for JSON (`name=value`), strings (`::`), raw JSON (`:=`), forms (`--form`), files (`@path`), and headers (`Key:value`). - Pretty-prints JSON and colorizes request/response. - Supports sessions, downloads, resumable transfers, multipart uploads. - Ships as a single ~5MB static binary. ## Architecture Overview xh is built on `reqwest` (hyper + rustls) and `clap`. A request parser translates CLI tokens into typed body/header/query segments, then hyper executes the request. Output is pretty-printed by `serde_json` and syntect. HTTP/2 and TLS come from rustls with no OpenSSL dependency. ## Self-Hosting & Configuration - Install via `brew install xh`, `cargo install xh`, or binary release. - Sessions stored as JSON in `~/.config/xh/sessions/`. - `XH_CONFIG_DIR` overrides location. - Works offline: `--offline` prints the request without sending. - Supports `.netrc`, client certs, proxies, and custom CA bundles. ## Key Features - HTTPie-compatible syntax — muscle memory transfers. - ~3–6× faster cold start than HTTPie (no Python interpreter). - Single-binary distribution, ideal for containers and CI. - HTTP/2, HSTS, and rustls by default. - Session support and `--download` with resume. ## Comparison with Similar Tools - **HTTPie (Python)** — same UX; heavier install, slower startup. - **curl** — ubiquitous but verbose; no JSON shorthand. - **curlie** — curl wrapper in Go with HTTPie syntax; fewer features than xh. - **Hurl** — file-based runner for test suites; different use case. - **Bruno/Postman** — GUI and collections; xh is CLI-only. ## FAQ **Q: Is xh a drop-in replacement for HTTPie?** A: 95% — most recipes work unchanged; a few niche flags differ. **Q: Does it support HTTP/3?** A: Experimental via `--http3` when built with the `http3` feature. **Q: How do I pin TLS versions?** A: `--tls 1.3` forces TLS 1.3. **Q: Can I import an HTTPie session?** A: Copy the JSON into `~/.config/xh/sessions//.json`. ## Sources - https://github.com/ducaale/xh - https://crates.io/crates/xh --- Source: https://tokrepo.com/en/workflows/bc2fcb99-389d-11f1-9bc6-00163e2b0d79 Author: AI Open Source