Repolode
joewalnes

joewalnes/websocketd

A small CLI tool that wraps any STDIN/STDOUT program as a WebSocket server, like inetd for WebSockets.

Stars
17,459
Forks
1,009
Open issues
1
Last commit
2 months ago

What is it?

websocketd lets you expose an existing command-line program over WebSocket without writing any networking code. When a client connects, it starts the program, forwards each incoming message to the program's STDIN followed by a newline, and sends every line the program writes to STDOUT back to the client as a WebSocket message. When the connection closes, the process is shut down.

Because the interface is just standard streams, the same script runs unchanged from a terminal, in a shell pipeline, or as a WebSocket endpoint. The project is distributed as a single executable for Linux, macOS and Windows. Beyond WebSocket serving, it includes a static file server and a CGI server, exposes CGI environment variables describing the request, and offers a built-in developer console for testing frames in the browser.

It supports listening on a Unix domain socket, optional forwarding of STDERR tagged as JSON, and teardown of the whole process group when a client disconnects.

Key features

  • 01Wraps any program that reads STDIN and writes STDOUT as a WebSocket endpoint.
  • 02Ships as a single executable for Linux, macOS and Windows with no external dependencies.
  • 03Passes HTTP request details to scripts through CGI environment variables.
  • 04Includes a static file server and a classic CGI server.
  • 05Can listen on TCP or Unix domain sockets, and optionally forward STDERR.
  • 06Provides a built-in developer console for sending and inspecting frames.

Use cases

  • Prototyping a browser front end for an existing shell script or CLI tool.
  • Streaming live system output such as logs or vmstat stats to a web dashboard.
  • Building a quick browser-based REPL around a command-line interpreter.
  • Testing WebSocket message handling in a script before writing a JavaScript client.

Quick start

  1. 1

    Install on macOS with Homebrew

    brew install websocketd
  2. 2

    Or download the single executable for your OS from the install page

  3. 3

    Save a script such as count.sh and run it as a WebSocket server on port 8080

    websocketd --port=8080 ./count.sh

Things to know

  • Installing via Homebrew is only a one-line path on macOS; other systems need a manual download.

In collections

Topics

FAQ

What is websocketd?
A small CLI tool that wraps any STDIN/STDOUT program as a WebSocket server, like inetd for WebSockets. websocketd lets you expose an existing command-line program over WebSocket without writing any networking code. When a client connects, it starts the program, forwards each incoming message to the program's STDIN followed by a newline, and sends every line the program writes to STDOUT back to the client as a WebSocket message. When the connection closes, the process is shut down.
Is websocketd free to use? What license does it have?
websocketd is open source under the BSD-2-Clause license. Check the license terms before using it in commercial products.
Is websocketd still maintained?
Updated within 6 months. The last commit to websocketd was on Sep 7, 2026.
What can I use websocketd for?
Prototyping a browser front end for an existing shell script or CLI tool. Streaming live system output such as logs or vmstat stats to a web dashboard. Building a quick browser-based REPL around a command-line interpreter. Testing WebSocket message handling in a script before writing a JavaScript client.
How do I install websocketd?
Install on macOS with Homebrew: brew install websocketd Or download the single executable for your OS from the install page Save a script such as count.sh and run it as a WebSocket server on port 8080: websocketd --port=8080 ./count.sh
Where can I get websocketd?
The source code and installation instructions are on GitHub: https://github.com/joewalnes/websocketd

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects