https://github.com/kevinschweikert/proto
Render network packet field diagrams as ASCII art, Unicode art, or Mermaid.js.
https://github.com/kevinschweikert/proto
cli protocol rust rust-lang
Last synced: 19 days ago
JSON representation
Render network packet field diagrams as ASCII art, Unicode art, or Mermaid.js.
- Host: GitHub
- URL: https://github.com/kevinschweikert/proto
- Owner: kevinschweikert
- Created: 2026-05-28T22:31:28.000Z (24 days ago)
- Default Branch: main
- Last Pushed: 2026-05-29T20:54:49.000Z (23 days ago)
- Last Synced: 2026-05-29T22:12:13.559Z (23 days ago)
- Topics: cli, protocol, rust, rust-lang
- Language: Rust
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# proto
[](https://github.com/kevinschweikert/proto/actions/workflows/ci.yml)
Render network packet field diagrams as ASCII art, Unicode art, or Mermaid.js.
```bash
proto udp --unicode --clean
```
Output:
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
╭───────────────────────────────┬───────────────────────────────╮
│ Source Port │ Destination Port │
├───────────────────────────────┼───────────────────────────────┤
│ Length │ Checksum │
├───────────────────────────────┴───────────────────────────────┤
┊ Data ┊
╰───────────────────────────────────────────────────────────────╯
```
## Installation
```bash
cargo install --git https://github.com/kevinschweikert/proto.git
```
## Synopsis
```bash
proto --help
```
Output:
```
Usage: proto [OPTIONS] [DEFINITION]
Arguments:
[DEFINITION] Protocol name or inline definition
Options:
-u, --unicode Output in unicode style
-m, --mermaid Output a mermaid.js spec
-c, --clean remove crosses for each bit in a field for cleaner rendering
-b, --bits-per-row number of bits per row [default: 32]
-n, --no-ruler omit the bit number header
-l, --list list available protocols
-f, --from-kaitai path to a kaitai spec file
-h, --help Print help
```
## Packet Definitions
A packet definition is a comma-separated list of `label:bits` pairs:
```
"SourcePort:16,DestPort:16,Length:16,Checksum:16,Data:*"
```
## Examples
**ASCII:**
```bash
proto "SourcePort:16,DestPort:16,Length:16,Checksum:16,Chunk:64,Data:*"
```
Output:
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SourcePort | DestPort |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Chunk |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: Data :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
**Unicode:**
```bash
proto --unicode "SourcePort:16,DestPort:16,Length:16,Checksum:16,Chunk:64,Data:*"
```
Output:
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
╭─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮
│ SourcePort │ DestPort │
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│ Length │ Checksum │
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│ Chunk │
├ ┤
│ │
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
┊ Data ┊
╰─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─╯
```
**Mermaid.js:**
```bash
proto --mermaid "SourcePort:16,DestPort:16,Length:16,Checksum:16,Data:*"
```
Output:
```
packet
+16: "SourcePort"
+16: "DestPort"
+16: "Length"
+16: "Checksum"
+32: "Data"
```
**Built-in shortcuts:**
```bash
proto --list
```
Output:
```
Available Protocols:
Layer 4 (Network):
ip Internet Protocol Version 4
Layer 4 (Transport):
udp User Datagram Protocol
tcp Transmission Control Protocol
```
Use like this:
```bash
proto tcp
```
## Kaitai
> [!NOTE]
> Only a minimal subset of the spec will be parsed and supported
A [Kaitai Struct](https://kaitai.io/) specification can be loaded and visualized via:
```bash
proto --from-kaitai [PATH TO FILE]
```