LZ4 to Base64 Converter: Compress and Encode Data
Compress text or a file into a standard LZ4 frame and get it as Base64 text for JSON fields, API payloads and database columns. Runs in your browser.
How to Use the LZ4 to Base64 Converter
Input Your Data
Start with the data you want to compress. The page combines LZ4 compression with Base64 encoding in one step, which is handy when compressed data has to live in a database text column, an API body or a JSON field. You can:
Example: Input JSON Data
A short JSON document before compression and encoding:
{ "user": { "id": "USR-98765", "name": "Alex Chen" } }
Automatic LZ4 Compression
There is no button to press. Half a second after you stop typing, the page:
Example: Base64 Encoded Output
This is the output for the Step 1 example:
BCJNGEBw30IAAIB7CiAgInVzZXIiOiB7CiAgICAiaWQiOiAiVVNSLTk4NzY1IiwKICAgICJuYW1lIjogIkFsZXggQ2hlbiIKICB9Cn0AAAAA
The 66 bytes of JSON became an 81-byte LZ4 frame, 108 characters once Base64-encoded. A snippet this short has nothing to compress and the frame header makes it bigger; longer files with repeated keys and values shrink a lot.
Copy or Download the Base64
Take the Base64 string wherever it needs to go:
Frequently Asked Questions
What exactly does this page produce?
A standard LZ4 frame, the same format the lz4 command-line tool writes and reads, encoded as Base64. The frame starts with the LZ4 magic number, so the Base64 always begins with "BCJNGE". The reference liblz4 library and the lz4 tool read it back to exactly the bytes you put in.
Why would I want LZ4 data as Base64?
LZ4 output is binary, and raw bytes break in JSON strings, query parameters, environment variables and most text columns. Base64 rewrites them using only letters, digits, + and /, so the compressed data can sit in any text field and come back byte for byte on the other side.
Will the Base64 be shorter than my original text?
Only when the data repeats itself a lot. An LZ4 frame adds at least 15 bytes of header and end marker, and Base64 makes the result about a third longer, so short snippets grow: the 66-byte example on this page becomes an 81-byte frame and 108 characters of Base64. Larger files with repeated keys shrink properly; 200 similar JSON lines (9,689 bytes) came out as a 1,065-byte frame. The badge above the output shows the real sizes for whatever you enter.
How do I get the original data back?
Decode the Base64, then decompress the frame. In Python that is lz4.frame.decompress(base64.b64decode(s)); on the command line, base64 -d file.lz4.base64 | lz4 -dc > original. You can also paste the string into our Base64 to LZ4 decoder. Note that this is the frame format, not a raw LZ4 block, so code that calls a block-level decompress function will not read it.
Can I upload a file, including a binary one?
Yes, any file. Text files appear in the editor; images and other binary files don't, but they are compressed from their raw bytes, BOM and Windows line endings included, so decoding later gives back the identical file. Download saves the Base64 text as a .lz4.base64 file named after your upload. An empty file is refused and your input stays as it was.
How is this different from the LZ4 compression tool?
Both write the same LZ4 frame. This page is about the text form: Copy and Download give you the Base64 string you see. The LZ4 compression tool downloads the raw .lz4 bytes instead, which is what you want for a file on disk.
Does my data leave the browser?
No. Compression and Base64 encoding run in your browser. Nothing you paste or upload is sent to our server, and nothing is kept: reload the page and the editor starts empty.
Related Tools
LZ4 Compressor
Compress text or a file with LZ4 in your browser and download the .lz4 file or its Base64
LZ4 Decompressor
Decompress an .lz4 file or LZ4 Base64 in your browser, with checksums checked
Base64 to LZ4
Base64 to LZ4 decompressor - Decode Base64 and decompress LZ4 data to restore original content. Fast Base64 LZ4 decoder
Base64 Validator
Validate Base64 encoded strings with detailed format checking and content type detection
Image to Base64
Convert images to Base64 encoded strings for embedding in HTML, CSS, and APIs
Base64 to Image
Decode Base64 encoded strings to view and download images (PNG, JPG, GIF, SVG)