Blog · How-To

PowerShell Base64 Decode: Commands and Examples

Decode Base64 strings in PowerShell using built-in commands. No modules, no dependencies. Works on Windows, Linux, and Mac.

Need to decode Base64 in PowerShell? You do not need any external libraries. PowerShell has built-in .NET methods that handle Base64 encoding and decoding in a single line. Here is everything you need.

Decode a Base64 String

# Standard Base64 decode
[System.Text.Encoding]::UTF8.GetString(
    [System.Convert]::FromBase64String("SGVsbG8gV29ybGQ=")
)
# Output: Hello World

Encode a String to Base64

# Convert plain text to Base64
[System.Convert]::ToBase64String(
    [System.Text.Encoding]::UTF8.GetBytes("Hello World")
)
# Output: SGVsbG8gV29ybGQ=

Decode Base64 from a File

$base64 = Get-Content -Raw "encoded.txt"
$bytes = [System.Convert]::FromBase64String($base64)
[System.IO.File]::WriteAllBytes("output.bin", $bytes)

Decode a Script Block (Suspicious Commands)

Attackers sometimes hide PowerShell commands in Base64. If you see a suspicious encoded string, decode it:

# Powershell often uses Unicode (UTF-16LE) for encoded commands
[System.Text.Encoding]::Unicode.GetString(
    [System.Convert]::FromBase64String($encoded)
)

For quick one-off decoding without opening PowerShell, try our free online Base64 decoder. Paste any string and get instant results in your browser.

Decode Base64 without PowerShell

Paste any Base64 string and decode it instantly. No installs, no commands.

Open Base64 Tool