Decoding Base64 With PowerShell

Published: (January 6, 2026 at 07:35 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Introduction

Developers often encounter Base64 strings in configuration files or API responses. They represent binary data in a text format. While Linux users can decode these strings easily with the base64 command, Windows users typically lack a direct equivalent in PowerShell.

PowerShell relies on the .NET framework, which provides powerful system libraries for data manipulation. By using these libraries, you can decode Base64 strings without external tools.

How Base64 Decoding Works

  1. Base64 string → byte array
    Convert the Base64‑encoded string into a byte array.

  2. Byte array → readable text
    Decode the byte array into a string using an appropriate text encoding (UTF‑8 works for most modern text).

Step‑by‑Step Guide

Step 1: Define the Base64 string

$EncodedString = "SGVsbG8gV29ybGQ="   # Example: "Hello World"

Step 2: Convert the string to a byte array

$Bytes = [System.Convert]::FromBase64String($EncodedString)

Step 3: Decode the byte array to text

$DecodedText = [System.Text.Encoding]::UTF8.GetString($Bytes)

Result

Hello World

Benefits

  • Works on all modern versions of PowerShell.
  • No external tools required.
  • Ideal for automation scripts.

Understanding the underlying .NET types lets you manipulate data directly, embodying the PowerShell way of working with objects rather than treating commands as black boxes.

Back to Blog

Related posts

Read more »

C#.NET - day 08

Day 08 : Unit Testing — The Real Reason Interfaces Exist Proving service behavior without repositories or databases Introduction Many tutorials introduce inter...