Replace ‘curl’ with ‘xh’ for Syntax-Highlighted HTTP Requests

User avatar placeholder
Written by Tamzid Ahmed

June 18, 2026

Every developer has experienced the frustration of parsing through raw JSON responses in their terminal. The xh HTTP client solves this problem by providing syntax-highlighted, formatted output for all your HTTP requests, making API debugging significantly more efficient than traditional tools like curl.

Why Replace curl with the xh HTTP Client?

While curl remains a powerful tool for transferring data with URLs, its default output lacks readability, especially when dealing with complex JSON responses. xh (pronounced “ex-aitch”) is a modern, user-friendly HTTP client that serves as an excellent curl alternative with built-in syntax highlighting and automatic formatting.

The primary advantage of xh is its ability to transform raw API responses into readable, color-coded output without requiring additional tools like jq or python for formatting. This immediate visual feedback helps developers quickly identify issues, understand response structures, and iterate faster during development.

Key Benefits of xh Over curl

  • Automatic syntax highlighting for JSON, XML, and HTML responses
  • Intelligent formatting that makes complex data structures readable
  • Simplified syntax for common HTTP operations
  • Built-in authentication support for various methods
  • Response timing information to track API performance
  • Request/response history for debugging purposes

Installing xh on Your System

Getting started with xh is straightforward across different operating systems. The tool is written in Rust, ensuring performance and reliability while maintaining a small footprint.

Installation Methods

For macOS users, Homebrew provides the simplest installation method:

brew install xh

Linux users can install xh via their package manager or download the pre-compiled binary:

cargo install xh

Windows users can install xh using scoop or by downloading the executable from the GitHub releases page:

scoop install xh

After installation, verify that xh is working correctly by checking its version:

xh --version

Making Your First HTTP Request with xh

The basic syntax of xh closely resembles HTTPie, making it intuitive for developers familiar with that tool. Let’s explore how to make various types of requests.

Basic GET Request

A simple GET request to retrieve data from an API endpoint:

xh GET https://api.example.com/users

xh automatically applies syntax highlighting to the response, making it easy to read and understand the data structure. The color coding helps distinguish between keys, values, strings, and numbers at a glance.

POST Request with JSON Data

Sending data to an API endpoint is equally straightforward:

xh POST https://api.example.com/users name=John email=john@example.com

xh automatically converts the parameters into JSON format and sets the appropriate Content-Type header. You can also send raw JSON by using the = prefix:

xh POST https://api.example.com/users := '{"name":"John","email":"john@example.com"}'

Working with Headers and Authentication

Adding custom headers to your requests is simple with xh:

xh GET https://api.example.com/data Authorization:Bearertoken

xh supports various authentication methods out of the box:

  • Bearer token: xh GET https://api.example.com/data --auth bearer token
  • Basic auth: xh GET https://api.example.com/data --auth user:password
  • Digest auth: xh GET https://api.example.com/data --auth-type digest --auth user:password

Advanced xh Features for API Debugging

Beyond basic requests, xh offers several advanced features that make it a powerful tool for API development and debugging.

Response Formatting Options

While xh automatically formats responses, you can customize the output to suit your needs:

  • Pretty print: xh GET https://api.example.com/data --pretty=format
  • Colors: xh GET https://api.example.com/data --style=solarized
  • Sort keys: xh GET https://api.example.com/data --sort

Request and Response Inspection

xh provides detailed information about both requests and responses, which is invaluable for debugging:

xh GET https://api.example.com/data -v

The verbose flag (-v) shows the complete request headers, response headers, and body, helping you understand exactly what's being sent and received.

Session Management

For complex workflows requiring multiple requests with shared headers or cookies, xh offers session management:

xh --session=./session.json POST https://api.example.com/login username=user password=pass

Subsequent requests can use the same session to maintain authentication and state:

xh --session=./session.json GET https://api.example.com/profile

Comparing xh to Other HTTP Clients

While xh is an excellent choice for many developers, understanding how it compares to other popular HTTP clients helps you make an informed decision.

xh vs curl

xh provides a more user-friendly experience with automatic formatting and syntax highlighting, while curl offers more extensive protocol support and is available on virtually all systems by default. For most API development tasks, xh's readability advantages outweigh curl's broader protocol support.

xh vs HTTPie

xh is inspired by HTTPie but written in Rust for better performance and smaller binary size. The syntax is nearly identical, making migration between the two tools seamless. xh also provides some additional features like response timing information that HTTPie lacks in its core distribution.

xh vs Postman

While Postman offers a graphical interface with advanced features like automated testing and collection management, xh excels in terminal-based workflows and integrates better with shell scripts and command-line pipelines. For quick API testing and debugging, xh's speed and simplicity often make it the preferred choice.

Integrating xh into Your Development Workflow

To maximize the benefits of xh, consider incorporating it into your existing development processes.

Shell Scripting with xh

xh works seamlessly in shell scripts, making it ideal for automation tasks:

#!/bin/bash

response=$(xh GET https://api.example.com/data)

echo "$response" | jq '.results'

While xh provides excellent formatting, you can still pipe its output to tools like jq for complex data manipulation when needed.

CI/CD Pipeline Integration

xh is particularly useful in CI/CD pipelines for testing API endpoints:

xh GET https://api.example.com/health --check-status

The --check-status flag ensures that non-2xx responses result in a non-zero exit code, making it easy to fail builds when API tests don't pass.

Conclusion

Replacing curl with the xh HTTP client for your HTTP requests can significantly improve your API debugging workflow with its syntax-highlighted, formatted output. The tool's intuitive syntax, combined with powerful features like session management and detailed request/response inspection, makes it an invaluable addition to any developer's toolkit. Start by installing xh today and experience the difference that readable, color-coded API responses can make in your daily development tasks.

Leave a Comment