Base64 Encode in PowerShell

Easily convert text to Base64 using PowerShell


What is Base64 Encoding?

Base64 encoding is a method of converting binary data into an ASCII string format using a specific 64-character set. It is commonly used in data transmission and storage, allowing binary data to be represented in a textual format that can be easily transmitted over media designed to deal with textual data.

How to Use Base64 Encoding in PowerShell

To encode text in Base64 using PowerShell, you can utilize the built-in .NET methods. First, convert the string into a byte array, then use the [Convert]::ToBase64String() method to get the encoded string. This tool simplifies the process by allowing you to enter your text and get the Base64 encoded output with a single click.

Use Cases for Base64 Encoding

Base64 encoding is widely used for various applications, such as embedding images in HTML or CSS, transmitting complex data in APIs, and ensuring the integrity of data when sending it over text-based protocols like email. It is essential for developers and system administrators who work with data encoding and transmission.

Encoding mismatch breaks APIs

In 2026, the most common PowerShell Base64 bug is still using the wrong text encoding. `[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($s))` creates UTF-16LE output, which many APIs, JWT tools, and cloud CLIs reject because they expect UTF-8 bytes. In PowerShell 7+, prefer `[Text.Encoding]::UTF8.GetBytes($s)` unless a spec explicitly says otherwise. If you’re encoding `username:password` for Basic Auth, build the plain string first, then Base64 the UTF-8 bytes—don’t Base64 each part separately.