Upload a file
  1. base64hub
  2. Text tools
  3. UTF-16 to Base64

UTF-16 to Base64: Encode UTF-16LE or UTF-16BE Text

Text is converted to UTF-16 little-endian bytes, the format Windows and .NET use for strings, and then Base64-encoded. Switch the charset to UTF-16BE for big-endian systems.

Free no sign-up, no limits Local nothing uploaded LE / BE byte order selectable, no BOM Updated Oct 27, 2026
Input 0 BOutput 0 BSize –

Processed in your browser. This page cannot send your data anywhere – how we know

How to encode text as UTF-16 Base64

  1. Type or paste your text into Input · text. Charset is preset to UTF-16LE.
  2. Copy the Base64 from Output · Base64. The Input figure shows the UTF-16 byte count, twice the length of plain English text.
  3. For a big-endian consumer, switch Charset to UTF-16BE.
  4. Swap decodes the result again for a quick check; Base64 to UTF-16 is the dedicated decoder.

UTF-16LE vs UTF-16BE

UTF-16 stores each character as one or two 16-bit code units. Little-endian writes the low byte first, big-endian the high byte first. Windows and .NET use little-endian; Java’s UTF-16 encoder and many network formats use big-endian.

TextUTF-16LE bytesUTF-16LE Base64UTF-16BE Base64
Hi48 00 69 00SABpAA==AEgAaQ==
Hello10 bytesSABlAGwAbABvAA==AEgAZQBsAGwAbw==
€AC 20rCA=IKw=
👋3D D8 4B DCPdhL3A==2D3cSw==

Characters outside the Basic Multilingual Plane, including every emoji, take two code units called a surrogate pair. 👋 (U+1F44B) becomes D83D DC4B, which is the 4 bytes in the last row.

Since every ASCII letter is paired with a zero byte, UTF-16 Base64 of English text is dotted with A characters. An unknown string with that pattern is worth decoding as UTF-16.

Where UTF-16 Base64 is used

  • PowerShell -EncodedCommand. powershell -EncodedCommand RwBlAHQALQBEAGEAdABlAA== runs Get-Date. A frequent reason such commands fail is a script encoded as UTF-8. The PowerShell EncodedCommand tool adds the command prefix, warns about the length limit of cmd.exe and also decodes commands found in logs.
  • .NET code. Encoding.Unicode in C# is UTF-16LE, so Convert.ToBase64String(Encoding.Unicode.GetBytes(s)) produces the same output as this page.
  • Windows data. Strings from the registry, from NVARCHAR columns cast to binary in SQL Server and from many Windows APIs are UTF-16LE.

Byte order marks

This tool writes no byte order mark, which is what PowerShell and most APIs want. Some libraries add one automatically:

SourceFirst bytesBase64 of Hi
This tool, UTF-16LE48 00SABpAA==
Python "Hi".encode("utf-16")FF FE 48 00//5IAGkA
Java "Hi".getBytes(UTF_16)FE FF 00 48/v8ASABp

If your Base64 must match one of those, encode with an explicit byte order in code, as below.

UTF-16 to Base64 in code

import base64

base64.b64encode("Get-Date".encode("utf-16-le")).decode()   # 'RwBlAHQALQBEAGEAdABlAA=='
base64.b64encode("Hi".encode("utf-16-be")).decode()         # 'AEgAaQ=='
// Node.js has a little-endian codec only
Buffer.from("Get-Date", "utf16le").toString("base64");   // "RwBlAHQALQBEAGEAdABlAA=="
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes('Get-Date'))

Use utf-16-le rather than utf-16 in Python unless you want the BOM. More examples: Python, Node.js.

FAQ

Why does PowerShell need UTF-16LE Base64?

powershell -EncodedCommand expects the Base64 of the script’s UTF-16LE bytes, because that is how Windows stores strings internally. UTF-8 Base64 decodes to the wrong characters and the command fails. The PowerShell EncodedCommand tool builds the whole command line.

What is the difference between UTF-16LE and UTF-16BE?

The order of the two bytes in each code unit. H is 48 00 in little-endian and 00 48 in big-endian, so Hi encodes as SABpAA== or AEgAaQ==.

Will the output start with a byte order mark?

No, only the text’s own bytes are encoded. Python’s "utf-16" codec and Java’s UTF_16 charset do add one, which is why their Base64 starts with //5 or /v8.

Why is UTF-16 Base64 so long?

UTF-16 uses at least 2 bytes per character, so English text doubles in size before Base64 adds its third. Hello is 8 Base64 characters in UTF-8 and 16 in UTF-16.