Dumb Universal Markup Brutally Lightweight
Token reduction algorithm for LLM inputs. Compress JSON/TOML prompts while maintaining LLM readability.
LLMs understand text with missing vowels and abbreviated words due to linguistic redundancy. DUMBL exploits this to reduce token count (and costs) by 15-30%.
Original: "Desenvolva uma aplicaΓ§Γ£o completa utilizando programaΓ§Γ£o orientada"
DUMBL: "Desenvlva uma aplicΓ§ complta utiliznd programΓ§ orientda"
Savings: ~20% fewer tokens
Save money on API calls while maintaining semantic clarity for GPT-4, Claude, Llama, Gemini, and other LLMs.
- π 15-30% token reduction on typical LLM prompts
- π§ Three compression levels - light, medium, aggressive
- π¦ Zero dependencies - TOML support is optional
- π Multilingual - English & Portuguese optimized
- π Smart preservation - URLs, emails, paths, tech terms stay intact
- π TypeScript ready - Full type definitions included
- β‘ Fast - Minimal overhead for real-time use
npm install dumblFor TOML support (optional):
npm install dumbl @iarna/tomlconst { dumbl } = require('dumbl');
// Create instance (level 1-3)
const d = dumbl.aggressive(); // level 3
// Compress object
const result = d.compress({
prompt: "Explique detalhadamente o processamento"
});
// β { prompt: "Explqe detlhadmt o procesmt" }
// Output as JSON
const json = d.toJSON(data);
// Output as DUMBL format (most compact)
const compact = d.toDUMBL(data);
// Quick debug - see stats and result
const { dumblDry } = require('dumbl');
dumblDry(data); // logs stats + compressed resultconst { dumbl } = require('dumbl');
// With options
const d = dumbl({
level: 3, // 1=light, 2=medium, 3=aggressive
preserveKeys: true, // don't compress object keys
minWordLength: 3 // min chars to compress
});
// Presets
dumbl.light() // level 1 - safe, minimal
dumbl.medium() // level 2 - balanced
dumbl.aggressive() // level 3 - maximum compressionconst d = dumbl.aggressive();
// Compress anything
d.compress(object) // β compressed object
d.compress(jsonString) // β compressed object
d.compress(text) // β compressed string
// Output formats
d.toJSON(input) // β JSON string (compressed)
d.toDUMBL(input) // β DUMBL format (most compact)
// With TOML (requires @iarna/toml)
const TOML = require('@iarna/toml');
d.compress(tomlString, TOML)
d.toTOML(input, TOML)
// Parse DUMBL back
d.parseDUMBL(dumblString) // β object
// Statistics
d.stats(original, compressed)
// β { savedChars, ratio, estimatedTokensSaved, ... }const { compress, toJSON, toDUMBL, dumblDry } = require('dumbl');
// Quick compression (uses level 3)
compress({ prompt: "..." })
toJSON({ prompt: "..." })
toDUMBL({ prompt: "..." })
// Dry run - logs stats and result to console
dumblDry({ prompt: "..." })Use dumblDry to preview compression results with statistics:
const { dumblDry } = require('dumbl');
dumblDry({ prompt: "Explique detalhadamente o processamento de dados" });Output:
βββββββββββββββββββββββββββββββββββββββββββ
β DUMBL Dry Run β
βββββββββββββββββββββββββββββββββββββββββββ€
β Original: 56 chars
β Compressed: 44 chars
β Saved: 12 chars (21.4%)
β Est. tokens: ~3 saved
βββββββββββββββββββββββββββββββββββββββββββ€
β Result:
βββββββββββββββββββββββββββββββββββββββββββ
{
"prmpt": "Explque dtalhdamt o prcesmento de ddos"
}
| Level | Description | Use Case |
|---|---|---|
| 1 | Remove duplicates only | Conservative, max readability |
| 2 | + Suffix abbreviations | Balanced |
| 3 | + Vowel removal | Maximum savings |
Custom ultra-compact format, JSON-compatible:
// JSON
{"enabled":true,"count":null,"items":["a","b"]}
// DUMBL
{enabled:T,count:N,items:["a","b"]}Features:
T/Ffor booleansNfor null- Unquoted keys when possible
- No whitespace
npm run benchmarkSample results:
| Format | Size | vs JSON |
|---|---|---|
| JSON (pretty) | 1250 | +45% |
| JSON (compact) | 862 | baseline |
| TOML | 780 | -10% |
| JSON+DUMBL L3 | 680 | -21% |
| DUMBL format | 620 | -28% |
DUMBL intelligently preserves:
- β Short words (β€3 chars)
- β Connectors (the, of, de, para, etc.)
- β URLs, emails, file paths
- β Tech terms (API, JSON, HTTP, etc.)
- β Numbers and booleans
- β Object structure
Tested and confirmed readable by:
- β GPT-4 / GPT-4o / GPT-4o-mini
- β Claude 3.5 / Claude 4
- β Llama 3 / Llama 3.1
- β Gemini Pro / Gemini Ultra
- β Mistral / Mixtral
The compression maintains semantic meaning while reducing tokens.
Full type definitions included:
import { dumbl, DumblOptions, DumblStats } from 'dumbl';
const d = dumbl.aggressive();
const stats: DumblStats = d.stats(original, compressed);npm testContributions are welcome! Please read our Contributing Guide for details.
MIT Β© Frederico Bezerra
Frederico Bezerra
- Website: neosdev.io
- LinkedIn: @fredericobezerra
- GitHub: @fredericobezerra
If you find DUMBL useful, please β star the repo!