Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Log4TurtleShell
Frequent Visitor

How to Decode a Base64 Encoded Bookmark

I am using this library, https://github.com/microsoft/PowerBI-JavaScript, to embed reports and handle bookmarks. I am calling capture() from the bookmarksManager object on my report. This returns a bookmark with the state. The state is a base64 encoded string. I am trying to decode the string for testing purposes, but I can't get it to decode correctly. I have used Mime tools in Notepad++ and various online decoders, but they all return gibberish.

 

Is there a trick to decoding base64 encoded bookmark states?

7 REPLIES 7
klirium
New Member

@Log4TurtleShell @ozpbi123 

The state of bookmarks is gzipped, so after you decoded it from base64 you need to decompress it:

 

static class Program
{
    public static void Main()
    {
        // Replace with your actual Base64-encoded and gzipped string
        string encodedAndGzippedString = "";

        // Decode the Base64 string
        byte[] decodedBytes = Convert.FromBase64String(encodedAndGzippedString);

        // Decompress the gzipped data
        string decompressedString = DecompressGzip(decodedBytes);

        Console.WriteLine("Decompressed data:");
        Console.WriteLine(decompressedString);
    }

    public static string DecompressGzip(byte[] compressedData)
    {
        using (var memoryStream = new MemoryStream(compressedData))
        using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
        using (var reader = new StreamReader(gzipStream, Encoding.UTF8))
        {
            return reader.ReadToEnd();
        }
    }

}

 

 

 

Great post @klirium  - we've been struggling with trying to find a way to interpret saved bookmarks to handle updates when a change is made to a report and then the previous saved bookmarks become partially invalid.  I haven't tested your code, but I was able to verify the concept of base64 and decompress does work.  This site gives a nice way to plug in individual encoded bookmarks and see the plaintext  https://www.zickty.com/gziptotext

Anonymous
Not applicable

Hi @Log4TurtleShell ,

Please review the following links, hope they can help you.

Base64 encoding and decoding in client-side Javascript

How do I decode a Base64 encoded string in JavaScript?

console.log(atob('TXkgU3RyaW5nIFRvIEVuY29kZQ=='));

Base64 Decode a Value in Node.js

const plain = Buffer.from('dXNlcm5hbWU6cGFzc3dvcmQ=', 'base64').toString('utf8')  

Best Regards

Thank you for your reply.

 

Using atob() still returns gibberish. Am I wrong that the bookmark state should be able to be decoded to readable text?

Did you ever get a solution to this? I am also trying to decode the bookmark state, but unable to get anything other than gibberish as well.

I did.
You can use below python script to decode the bookmark State.
The output is a JSON. Hope this helps.

  • Base64 Decode: Convert the Base64-encoded string back to its binary form.
  • Gzip Decompress: Decompress the binary data to get the original string.
import base64
import gzip
from io import BytesIO

def decode_base64_gzip(encoded_string):
    # Step 1: Base64 decode
    decoded_data = base64.b64decode(encoded_string)
    
    # Step 2: Gzip decompress
    with gzip.GzipFile(fileobj=BytesIO(decoded_data)) as gzip_file:
        decompressed_data = gzip_file.read()
    
    return decompressed_data.decode('utf-8')

# Example usage
encoded_string = "your_base64_gzipped_string_here"
decoded_string = decode_base64_gzip(encoded_string)
print(decoded_string)

 

 

Unfortunately, I did not. 😞

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.