# websocat

> Command-line WebSocket client and server, like netcat, curl and socat for ws:// and wss://, with TCP/UNIX socket proxying and program execution.

Stars: 8.7k · Language: Rust · License: MIT · Categories: Network

- Repository: https://github.com/vi/websocat
- Page: https://www.trmn.sh/tools/websocat

## Install

- Homebrew: `brew install websocat`
- FreeBSD pkg: `pkg install websocat`
- Cargo: `cargo install websocat`

## Overview

websocat is a command-line client and server for WebSockets, comparable to netcat, curl and socat but for ws:// and wss:// endpoints. It has a simple client mode (`websocat ws://URL`), a simple server mode (`websocat -s port`), and an advanced mode that takes two address arguments (`websocat [FLAGS] [OPTIONS] <addr1> <addr2>`) in the style of socat, so any two endpoints can be connected.

Beyond plain connections, it can run an external program and connect its stdin/stdout to a WebSocket, proxy TCP connections to WebSockets and back (e.g. `ws-l:127.0.0.1:1234 tcp:127.0.0.1:22`), and broadcast messages between connected clients using `broadcast:mirror:`. It supports text and binary modes, conversion between lines (or null-terminated records) and messages, inetd mode, UNIX sockets including Linux abstract sockets, unauthenticated SOCKS5 servers, auto-reconnect and connection-reuse modes, and Nginx integration over TCP or UNIX sockets. Other options include `--jsonrpc` to format typed lines as JSON-RPC 2.0 calls (used in the README to drive Chromium's remote debugging port), deflate/gzip/zlib compression of binary messages, and `--print-ping-rtts` to print round-trip times.

Transports can be overridden, for example by calling an external program to handle SSL or proxying. Pre-built executables exist for Linux (glibc and musl), Windows, macOS and Android, and a container image is available at ghcr.io/vi/websocat. It suits developers testing or debugging WebSocket APIs, scripting against WebSocket services from the shell, and people bridging WebSocket traffic to ordinary TCP or stdio tools.

### Installation

```bash
# via Homebrew
brew install websocat
```

```bash
# via FreeBSD pkg
pkg install websocat
```

```bash
# via Cargo
cargo install websocat
```

## Alternatives

- [xh](https://www.trmn.sh/tools/xh.md): HTTP client that reimplements HTTPie's syntax with focus on improved performance and speed. (Rust, 8.2k stars)
- [trippy](https://www.trmn.sh/tools/trippy.md): Network analysis tool combining traceroute and ping functionality for diagnosing networking issues (Rust, 8.1k stars)
- [miniserve](https://www.trmn.sh/tools/miniserve.md): Single-binary, cross-platform CLI HTTP file server with auth, uploads, TLS, WebDAV, QR codes, and on-the-fly tar.gz/zip directory downloads. (Rust, 8.0k stars)
- [sshx](https://www.trmn.sh/tools/sshx.md): Shares a terminal session over the web with a single command, with real-time cursors, an infinite canvas of windows, and end-to-end encryption. (Rust, 7.7k stars)
- [spotify_player](https://www.trmn.sh/tools/spotify-player.md): Terminal Spotify client with streaming, Spotify Connect remote control, synced lyrics, audio visualization, daemon mode, and CLI commands. Requires Premium. (Rust, 7.3k stars)

---

Canonical: https://www.trmn.sh/tools/websocat
