Decompress Brotli in Java
Decode Brotli-compressed data in pure Java with no native libraries, no JNI, and no third-party dependencies. Runs on any platform with Java 17 or later.
JDeli decodes Brotli-compressed data in pure Java (Java 17+) with no native libraries, no JNI, and no third-party dependencies.
JDeli's Brotli filter is decompress-only. It decodes Brotli streams but does not encode them. If you need to compress data losslessly in pure Java, use Flate or LZW instead.
Decompress Brotli data in Java
Create a BrotliFilterOptions, set decompress mode, and call JDeli.filter().
// Decompress byte[]
BrotliFilterOptions options = new BrotliFilterOptions();
options.setMode(FilterOptions.FilterMode.DECOMPRESS);
byte[] decompressed = JDeli.filter(rawData, options);
// Decompress InputStream
BrotliFilterOptions options = new BrotliFilterOptions();
options.setMode(FilterOptions.FilterMode.DECOMPRESS);
JDeli.filter(inputStream, options, outputStream);How to decompress Brotli data in Java
- Add the JDeli JAR to your project classpath, or add it as a Maven or Gradle dependency.
- Create a
BrotliFilterOptionsobject and callsetMode(FilterOptions.FilterMode.DECOMPRESS). - Pass your compressed data and options to
JDeli.filter(). Use thebyte[]overload for small data or theInputStream/OutputStreamoverload for large streams.
Brotli is decode-only in JDeli, so there is no FilterMode.COMPRESS path for this filter.
See the full Brotli filter reference for every method signature.
JDeli vs Brotli4j for Brotli decoding
The common Java option for Brotli is Brotli4j, a JNI wrapper around Google's native Brotli library. It supports both encode and decode, but ships platform-specific native binaries. JDeli is pure Java and decode-only. The right choice depends on whether you need encoding and whether native binaries are acceptable in your deployment.
| Brotli4j | JDeli | |
|---|---|---|
| Decode (decompress) | Yes | Yes |
| Encode (compress) | Yes | No |
| Implementation | JNI wrapper over native C library | Pure Java |
| Native binaries | Ships per-platform .so / .dll / .dylib | None |
| Air-gapped / locked-down JVM | Requires loading native code | Runs anywhere the JVM runs |
| Minimum Java | Java 8 | Java 17 |
If you only need to decode Brotli and want to avoid native dependencies (for example in a security-restricted or air-gapped environment), JDeli covers it in pure Java. If you need to encode Brotli, use Brotli4j.
"I was looking specifically for a Java-based compression technique, I'm happy because it's taking up less space on the server."
- Kevin Lauder (ISC Engineering Senior Manager)
Common issues when decompressing Brotli in Java
JDeli does not encode Brotli.
There is no compress path for this filter. Calling the filter with
FilterMode.COMPRESS will not produce a Brotli stream. Use Flate or LZW for pure-Java
lossless compression, or Brotli4j if you specifically need Brotli encoding.
Brotli is not Gzip or Deflate.
A Brotli stream will not decode with an Inflater or a Flate filter. Confirm your input is actually
Brotli-encoded (HTTP responses use the Content-Encoding: br header) before choosing this filter.
Use streams for large data.
The byte[] overload of JDeli.filter() loads the full output into heap
memory. For large Brotli streams, use the InputStream/OutputStream overload to avoid
OutOfMemoryError.
Frequently Asked Questions
Can JDeli compress data with Brotli?
No. JDeli's Brotli filter is decode-only. It decompresses Brotli streams but does not encode them. For pure-Java lossless compression, use the Flate or LZW filters.
Does JDeli's Brotli decoder need native libraries?
No. It is implemented in pure Java with no JNI and no native binaries, unlike Brotli4j, which wraps Google's native C library. It runs on any platform with Java 17 or later.
How is JDeli different from Brotli4j?
Brotli4j encodes and decodes Brotli through a JNI wrapper over native code. JDeli decodes only, in pure Java, with no native dependencies. Choose JDeli for decode-only, native-free deployments; choose Brotli4j when you need encoding.
Related Compression Guides
Tutorials for compressing and decompressing image data in Java.
Extend Java capabilities
(works with your existing code!)
1.
2.
3.