EditSafely

UTF-16 Encode a String

Encode a string as its UTF-16 code units in hexadecimal.

Runs on your device, nothing uploaded

Format
Separator
Hex case
Try:

0 chars · 0 lines

Output

Encode a string as its UTF-16 code units in hexadecimal.

Type or paste above to see the result here.

Example: Encode

What you paste never leaves this tab

UTF-16 Encode a String is JavaScript that your browser has already downloaded, and it does the whole job on your own machine. On a normal site, the text you paste is sent to a server that can log it, cache it or keep it. Here it is read and transformed inside this tab and nowhere else.

  • No upload
  • No length limit
  • Works offline once loaded
  • Nothing stored or logged

How to use UTF-16 Encode a String

  1. 1. Paste the string. Enter any text into the input pane, including accented characters or emoji. UTF-16 Encode a String converts each character to its 16-bit code unit in hexadecimal.
  2. 2. Pick a Format, Separator and case. Choose a Format: plain hex, \u escapes for JavaScript or Java, 0x0041, or U+0041. Set the Separator (space, none, comma or your own) and Hex case. Code units per character shows which characters need a surrogate pair.
  3. 3. Copy the hex code units. Copy the resulting sequence of hexadecimal code units out of the output pane, ready to paste into a debugger, binary editor, or documentation of the encoding.

When to use UTF-16 Encode a String

UTF-16 Encode a String converts text into its raw UTF-16 code units, shown as hexadecimal values. Use it whenever you need to see the exact 16-bit values a string produces, particularly for characters that require surrogate pairs.

  • Preparing test data for a native application. You are writing a test for code that consumes wide-character strings and need the exact UTF-16 hex code units for a sample input to hard-code into the test.
  • Checking how an emoji encodes as a surrogate pair. You want to see the two 16-bit code units that make up an emoji or other character outside the basic multilingual plane, to understand or debug surrogate pair handling.
  • Documenting an encoding for a file format spec. You are writing documentation for a binary format that stores UTF-16 strings and need the exact hex code units for an example string to include in the spec.
  • Comparing UTF-16 output against UTF-8. You want to see how the same string encodes differently in UTF-16 versus UTF-8, particularly for characters that take more bytes in one encoding than the other.

Examples

Encode

Input

AÉ

Output

0041 00c9

An emoji as a JavaScript escape

Input

😀

Output

\ud83d\ude00

About the UTF-16 Encode a String tool

UTF-16 Encode a String does its work locally, right in the browser. Encode a string as its UTF-16 code units in hexadecimal. There is no upload step, no queue and no account, and your data never travels over the network.

It belongs to the String Tools collection on EditSafely, a set of 159 small, focused String utilities that share the same instant, private workspace.

You can shape the output with 3 settings, including Format, Separator and Hex case, and the result refreshes the moment you change one. 2 worked examples further down the page show exactly what the tool produces for real inputs.

Running locally also makes the tool fast and dependable: results appear as soon as your input does, there is no server outage that can take it down mid-task, and confidential data can be processed without a second thought.

Frequently asked questions

Does UTF-16 Encode a String cost anything?

Yes, it is completely free. All 2,943 tools on EditSafely work without an account, a subscription or usage limits.

Is it safe to paste sensitive or confidential data?

No data leaves your device. The whole tool is JavaScript that runs inside your browser tab, so there is no upload, no server-side processing and no log of what you did. If you disconnect from the internet after the page loads, it keeps working.

How much text can I process at once?

There is no fixed limit; your device's memory is the ceiling. Up to 10 MB the result updates as you type, after a short pause that grows with the size. Above 10 MB a Run button appears so typing stays smooth, and files open up to 50 MB. A very long result shows its first 2,000 lines on screen, while Copy and Download always include all of it.

Do I need to sign up or install anything?

Nothing to install and no account needed. Open the page in any up-to-date browser, including on a phone or tablet, and the tool is ready.

How do I use the result?

The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.