top of page

Quick and dirty Python script to Base64 decode a text file with GUI

This Python script allows a user to decode a Base64 string that is saved in a text file. This script utilizes TKinter, the premier choice for Graphical User Interface (GUI), to select a file, then decode the contents of the file into the console. This script is compatible with Windows, MacOS, and Linux hosts.

Code segment:

## PyBase64DecodeGUI: Written by Andrew Akers (

import os.path

from os import system

import tkinter as tk

from tkinter import filedialog

import base64

def file_prompt(): ## File Prompt

print("Please select the file that you would like to Base64 decode.\n\n")

#Clear Screen

if == 'posix':


if =='nt':



root = tk.Tk()


file_path_name = filedialog.askopenfilename()


encodedStr = open(file_path_name, encoding='utf8').read()


print ("Error: Could not find file or read data.\n\n")



print ("File opened successfully.\n\n")

print("File Path: " + file_path_name + "\n\n")

print ("Base64 Encoded text: " + encodedStr + "\n\n")

# Url Safe Base64 Decoding

decodedBytes = base64.urlsafe_b64decode(encodedStr)

decodedStr = str(decodedBytes, "utf-8")

print("Base64 Decoded text: " + decodedStr + "\n\n")

17 views0 comments
bottom of page