Compress a webpage into a shareable URL. This library enables you to encode HTML content, including social media metadata (Open Graph, Twitter Cards, JSON-LD), into compact URLs. It’s perfect for testing how web pages render on social platforms, prototyping lightweight HTML snippets, or sharing temporary web content without server storage.
The tool is hosted at: onthefly.dobuki.net.
Visit onthefly.dobuki.net to use the interactive editor:
The editor dynamically updates the browser URL with ?edit=1
for editing, while the shareable link uses ?u=...
for rendering.
Install the library via npm:
npm install compress-to-url
const { compressToUrl, decompressFromUrl } = require('compress-to-url');
async function example() {
const html = '<!DOCTYPE html><html><head><title>Test</title></head><body><h1>Hello</h1></body></html>';
// Compress
const { payload } = await compressToUrl(html, { inputType: 'string', mimeType: 'text/html' });
console.log('Compressed URL:', payload);
// Decompress
const { data } = await decompressFromUrl(payload);
console.log('Decompressed HTML:', data);
}
example();
To build the library:
./build.sh
To run the local example:
./sample.sh
This project started as a way to test social media metadata on the fly, without hosting or complex setups. Built as an experiment in Vibe coding (intuitive, flow-driven development), it uses Cloudflare Workers to serve pages serverlessly. To avoid storage costs, all content is encoded in the URL itself, making every page self-contained.
Cloudflare Workers: Enables server-side rendering for social platform scraping, keeping costs low. No Storage: Pages are generated from URL parameters, eliminating database needs. React + TypeScript: The editor is built for a smooth, interactive experience. Compression: Efficiently encodes HTML to fit within URL length limits. Contributing Feel free to open issues or submit pull requests on GitHub. Feedback and ideas are welcome!