Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including wscat2 with all npm packages installed. Try it out:

wscat2 lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("wscat2/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

wscat2 v2.4.0

Unix-style WebSocket cat

wscat2 Build Status

Unix-style WebSocket cat (or netcat for websockets).


npm install -g wscat2


$ wscat -h
usage: wscat [-h] [-v] [-l PORT] [-b] [-H HEADER] [-n] [-k] [-d] [-s SUBP] [address]

Positional arguments:

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  -l PORT, --listen PORT
                        Start a websocket server on PORT.
  -b, --binary          Use binary WebSockets.
  -H HEADER, --header HEADER
                        Specify a custom HTTP request header. May be given
                        multiple times.
  -n, --no-check        Do not check for unauthorized certificates.
  -k, --keep-open       Do not close the socket after EOF.
  -d, --deflate         Use per-message deflate.
  -s SUBP, --subprotocol SUBP
                        WebSocket subprotocol


If you ever used nc, wscat works pretty much the same.

Connect to a server

$ wscat
Who's there?
Who's there?



$ wscat -l 12345
Hi there!
It's nice to speak to someone who just dosn't repeat everything I say back at me.
Yeah! Isn't it?!
Sorry, gotta run...


$ wscat localhost:12345
Hi there!
It's nice to speak to someone who just dosn't repeat everything I say back at me.
Yeah! Isn't it?!
Sorry, gotta run...

Transfer a file


$ wscat -b -l 12345 < ~/Desktop/mycat.jpg


$ wscat -b localhost:12345 > igotacat.jpg

Note that you can have the client send the file as well, after the connection has been setup wscat does not differentiate between server/client.

Get your bitcoin on

$ echo '{"op":"unconfirmed_sub"}' | wscat -k wss://

The -k option is used to keep the socket open after the command has been sent, allowing us to read the continuous stream of Bitcoin transactions.


This node.js program is written in TypeScript and has a compile step that you can run with make lib. For developing it is convenient to install the ts-node and typescript modules globally (npm i -g ..), this will allow you to directly execute the programs entry-point: ./src/cli.ts.

Use make test to run the tests and lint check and make lint to run the linter in formatter mode.


BSD 3-Clause

       /\_/\                    /\_/\
      / 0 0 \                  / o o \
     ====v====                ====C====          __   __
      \  W  /                  \  V  /         _(  )_(  )_
      |     |     _            |     |     .-=(_   WEB  _)
      / ___ \    /             / ___ \    /     (__   __)
     / /   \ \  |             / /   \ \  |        (__)
    (((-----)))-'            (((-----)))-'
     /                        /
    (      ___      ___      /
     \__.=|___|E    3__|=.__/
            /       ^


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free