Open Source · MIT License · npm
Smaller packets.
Longer messages.
Less congestion.
Meshperanto is a word-level Huffman codec built for Meshtastic LoRa mesh networks. It compresses natural language by 1.5–2.5× so you can say more, transmit faster, and leave more room on the channel for everyone.
01 / why it existsThe problem with bytes
LoRa is a remarkable technology. It can carry a signal miles on a coin-cell battery but that range comes at a cost: bandwidth measured in hundreds of bytes, not kilobytes. At 237 bytes per Meshtastic packet, a verbose status message can consume your entire budget before you've said anything useful.
Meshperanto applies a canonical Huffman code over
the 1,000 most frequent English words — drawn from Peter Norvig's
word-frequency analysis of a trillion words of text, widely regarded
as the gold standard for English frequency data. Common words like
the, is, and you compress to
just 4–5 bits. Less common words fall back gracefully to raw UTF-8.
The result: real-world sentences typically shrink by half.
The codec is stateless and self-contained. No handshake, no shared session, no dictionary negotiation over the wire. Both sides just need the same npm package.
02 / installationGet started in seconds
import { encode, decode } from 'meshperanto'; // Encode a message to a compact Uint8Array const bytes = encode('This is a test of the emergency broadcast system.'); // Decode back to the original string const text = decode(bytes); // → 'This is a test of the emergency broadcast system.'
Both ESM and CJS builds are included. TypeScript types are bundled.
03 / how it worksBits, not bloat
Every encoded message begins with a 16-bit word count header, followed by one token per word. Each token opens with a 2-bit prefix that tells the decoder what follows:
| Prefix | Meaning | Followed by |
|---|---|---|
| 00 | Normal word (lowercase) | Huffman codeword |
| 01 | Title Case word | Huffman codeword |
| 10 | ALL CAPS word | Huffman codeword |
| 11 | Out-of-vocabulary escape | 8-bit length + raw UTF-8 bytes |
Huffman code lengths are assigned by frequency rank using
⌊log₂(rank + 2)⌋ + 4, giving a minimum of 4 bits for
the most common words and up to ~14 bits for the rarest. The
assignment is canonical — both encoder and decoder
derive identical tables independently from the same sorted word
list, so no codebook needs to be transmitted.
Here's what the bitstream looks like for the word "This":
7 bits total for a 4-byte word.
04 / roadmapWhat's next
v1.0 is intentionally scoped. Here's where it's headed:
- v1.0 ✓ Canonical Huffman codec, 1000-word English dictionary, capitalisation flags, OOV escape path, 14/14 tests passing
- future Domain word extensions for amateur radio Q-codes, emergency management terminology, GPS coordinate shorthands
- future C port for on-device use directly in Meshtastic firmware
- future Python port for Raspberry Pi nodes and server-side gateways
- future Multi-language dictionaries (Spanish, French, German)