A client-side decoder for parsing Base64 encoded Gzipped text, useful if you are wanting to log larger blobs of text, but don't want to have big log messages.
You can access the tool online at https://logdecoder.atomsproject.com/
Data Encoding Process
The data encoding process involves three steps:
- Serialize data to JSON
- Compress the JSON using GZip
- Encode the compressed data as Base64
This process significantly reduces the size of large log messages while maintaining readability and compatibility.
Examples
C# Example
using System.IO.Compression; using System.Security.Cryptography; using System.Text; using System.Text.Json; public async Task<string> EncodeData<T>(T data) { using var base64Output = new MemoryStream(); await using (var cryptoStream = new CryptoStream( base64Output, new ToBase64Transform(), CryptoStreamMode.Write)) await using (var gzipStream = new GZipStream(cryptoStream, CompressionMode.Compress)) { // Serialize directly into the gzipStream. await JsonSerializer.SerializeAsync(gzipStream, data); } return Encoding.Default.GetString(base64Output.ToArray()); }
Python Example
import json import gzip import base64 def encode_data(data): // Serialize to JSON json_data = json.dumps(data).encode('utf-8') // Compress with GZip and encode as Base64 compressed = gzip.compress(json_data) base64_encoded = base64.b64encode(compressed).decode('utf-8') return base64_encoded
JavaScript Example
async function encodeData(data) { // Serialize to JSON const jsonString = JSON.stringify(data); const jsonBytes = new TextEncoder().encode(jsonString); // Compress with GZip const compressed = await new Response( new Blob([jsonBytes]).stream().pipeThrough( new CompressionStream('gzip') ) ).arrayBuffer(); // Encode as Base64 const base64String = btoa( String.fromCharCode(...new Uint8Array(compressed)) ); return base64String; }
Usage
- Encode your data using one of the examples above
- Copy the resulting Base64 string
- Paste it into the decoder on this website
- View the decoded and formatted data
Benefits
- Reduced Size: GZip compression significantly reduces the size of large log messages
- Compatibility: Base64 encoding ensures the data can be safely transmitted and stored
- Client-Side: All decoding happens in the browser, no server processing required
- Privacy: No data is sent to external servers
Technical Details
The encoding process follows these steps:
- Data is serialized to JSON using the native serializer for each language
- The JSON string is compressed using GZip compression
- The compressed data is encoded as Base64 to ensure safe transmission
The decoder reverses these steps to display the original data in a readable format.