diter89speedtest
v2.0.0
Published
Modern internet speed test library & CLI using Cloudflare — measure download, upload, ping & jitter with zero dependencies
Maintainers
Readme
diter89speedtest
Modern internet speed test library & CLI using Cloudflare endpoints — measure download, upload, ping & jitter with zero runtime dependencies.
Features
- Download speed — progressive multi-size test (1MB → 10MB → 25MB)
- Upload speed — POST test to Cloudflare
- Ping & Jitter — 10-sample latency test with min/max/avg/jitter
- ISP detection — auto-detect IP, ISP, server location via Cloudflare trace
- CLI — run
npx diter89speedtestfor instant results - Programmatic API — use as a library in your Node.js app
- Zero dependencies — only Node.js built-ins
- Pretty output — boxed terminal output with emoji
- JSON mode —
--jsonflag for scripting - Simple mode —
--simplefor one-line output
Install
npm install diter89speedtestCLI Usage
# Pretty output (default)
npx diter89speedtest
# JSON output for scripting
npx diter89speedtest --json
# Simple one-line output
npx diter89speedtest --simpleCLI Output Example
╔══════════════════════════════════════════╗
║ 🚀 Speed Test Results ║
╠══════════════════════════════════════════╣
║ ISP: Mozilla/5.0... ║
║ IP: 103.xxx.xxx.xxx ║
║ Server: CGK ║
╠══════════════════════════════════════════╣
║ Ping Avg: 12 ms ║
║ Ping Min: 8 ms ║
║ Jitter: 3 ms ║
╠══════════════════════════════════════════╣
║ Download: 45.23 Mbps ║
║ Upload: 22.10 Mbps ║
╚══════════════════════════════════════════╝
Timestamp: 2025-07-07T12:00:00.000ZProgrammatic API
const { runSpeedTest, SpeedTest } = require('diter89speedtest');
// Quick run
const result = await runSpeedTest();
console.log(result.download.formatted); // "45.23 Mbps"
console.log(result.upload.formatted); // "22.10 Mbps"
console.log(result.ping.avg); // 12
// With options & progress
const test = new SpeedTest({
downloadSizes: [1e6, 1e7], // Custom download sizes (bytes)
uploadSize: 1e6, // Custom upload size (bytes)
pingCount: 20, // Number of ping samples
timeout: 60000, // Request timeout (ms)
onProgress: (phase, msg) => {
console.log(`[${phase}] ${msg}`);
},
});
const result = await test.run();Result Object
{
timestamp: string; // ISO 8601
isp: {
ip: string; // Your public IP
isp: string; // User agent / ISP info
colo: string; // Cloudflare colo code
location: string; // Lat,Lng
};
ping: {
avg: number; // Average ping (ms)
min: number; // Minimum ping (ms)
max: number; // Maximum ping (ms)
jitter: number; // Jitter (ms)
};
download: {
speed: number; // Raw speed (bps)
formatted: string; // Human-readable (e.g. "45.23 Mbps")
bytes: number; // Total bytes downloaded
elapsed: number; // Total time (seconds)
samples: number; // Number of download tests
};
upload: {
speed: number; // Raw speed (bps)
formatted: string; // Human-readable
bytes: number; // Total bytes uploaded
elapsed: number; // Total time (seconds)
};
}API Reference
| Export | Type | Description |
|--------|------|-------------|
| SpeedTest | Class | Full speedtest with configurable options |
| runSpeedTest(options?) | Function | Convenience wrapper — runs test and returns result |
| formatSpeed(bps) | Function | Format bits/sec to human-readable string |
| formatBytes(bytes) | Function | Format bytes to human-readable string |
| cli() | Function | Run CLI mode programmatically |
License
ISC
