How to Compress Text or Files with Brotli
Input Your Data
Anything can go in: plain text, JSON, XML, a JavaScript bundle or a binary file. Brotli is the compression format Google designed for the web, and on text it usually beats GZIP. You can get your data in three ways:
Example: Uncompressed JSON Input
Here's the start of the sample JSON before compression:
{ "operator": "GlobalTel Networks", "subscribers": [ { "id": "TEL-9001", "plan": "5G Unlimited Premium", "monthly_fee": 89.99 } ] }
Automatic Compression
There is no Compress button. Half a second after you stop typing (or as soon as a file is loaded), the page:
Example: The Sample JSON After Compression
These are the real numbers for the Sample button's JSON:
Download or Copy Compressed Data
The two buttons above the output give you the same compressed bytes in two forms:
Frequently Asked Questions
What do I get when I press Download?
A real Brotli file: the raw compressed bytes, saved as compressed.br for pasted text or as yourfile.ext.br when you uploaded a file. It is the same format the brotli command-line tool writes, so brotli -d file.br turns it back into the original. The Base64 text in the output panel is those same bytes, there so you can copy them into JSON, a config file or a test.
Can I use the .br file as a precompressed asset on my web server?
Yes. Servers that serve precompressed files (for example nginx with brotli_static, or a static host that picks up .br files) expect app.js.br to sit next to app.js. Upload app.js here, download app.js.br and put it beside the original. The server then sends it with Content-Encoding: br to browsers that ask for Brotli, which is every current browser over HTTPS.
Will an uploaded file come back exactly the same after decompressing?
Yes. Uploads are read as raw bytes, not as text, so a byte order mark, Windows line endings, an image or a ZIP all go into the compressor unchanged, and decompressing the .br gives back the identical file. Text files are also shown in the editor; binary files aren't shown, and a note above the editor tells you the file is being used.
How much smaller will my data get?
It depends entirely on the data. The page's own sample, a 494-byte JSON document, comes out at 225 bytes, about 54% smaller. Long, repetitive text such as logs, CSV exports or minified JavaScript usually shrinks much more. Images, video and ZIP files are already compressed and barely change. The badge above the output always shows the real sizes for what you entered.
Why does the badge say my output is larger?
A Brotli stream starts with a few bytes of its own, so a single word or a very short line comes out bigger than it went in. The badge turns amber and says how much larger instead of showing a negative saving. Compression starts to pay off once there is some repetition to work with.
How is this different from Brotli to Base64?
Both compress with Brotli. This page is for when you want the file itself: Download saves the binary .br. The Brotli to Base64 converter is for when you need text you can paste somewhere, and its download is a Base64 text file.
How do I decompress the result?
On the command line run brotli -d compressed.br. In code, Node.js has zlib.brotliDecompressSync and Python has brotli.decompress. If you copied the Base64 instead, paste it into our Brotli decompression tool to get the original text back.
Is my data uploaded anywhere?
No. Compression runs in your browser through WebAssembly, so what you paste or upload is never sent to our server, and nothing is kept after you close or reload the page.
Related Tools
Brotli Decompressor
Open a .br file or Brotli Base64 in your browser and get the original bytes back
Brotli Unzip
Brotli unzip tool - Unzip and extract .br files online. Fast Brotli extractor and unbrotli decompression
JavaScript Compressor
Advanced compression with multiple optimization levels
CSS Compressor
Compress and minify CSS code
Brotli to Base64
Compress data with Brotli and encode to Base64 format
Base64 to Brotli
Decode Base64 and decompress the Brotli data inside it