Unicode, emoji and HTML entities: choose the correct conversion

Understand visible characters, UTF-8 Base64 and single-pass HTML decoding, with a working browser example and direct tool links.

Content reviewed ·

The problem and context

A visible character is not always one JavaScript code unit. An accented letter can contain a base letter plus a combining mark, and a family emoji can contain several joined symbols. A reversal that splits individual code units can damage this text. Encoding creates a different problem: Base64, URL escapes, Unicode escapes and HTML entities each have their own rules and destination.

Method and calculation

Choose the format before choosing the button. Use String processing for an individual operation, Encoder for format conversion and Text reverser for reversal options. The grapheme-based reversal keeps visible clusters together. UTF-8 Base64 first converts text into bytes; decoding requires valid UTF-8 bytes. HTML entity decoding resolves one layer of character references. It does not sanitize markup or repeatedly decode its own output. Use an HTML-aware sanitizer when your application needs to render untrusted HTML.

Worked example

Reverse A👨‍👩‍👧‍👦é🚀 and the result is 🚀é👨‍👩‍👧‍👦A: both the family and the accented letter remain intact. Encode 中文🙂 as UTF-8 Base64 to obtain 5Lit5paH8J+Zgg==, then decode it to recover the original. One HTML decode of < produces the literal text <, not a less-than sign. Edit the text below and try reversal, Base64 encoding and HTML decoding separately, comparing the output at each step.

Checklist

Base64 represents bytes as text; decoding recovers the content. Spaces and line breaks are data too. Keep the original and decode one layer according to the destination format. Use textContent when inserting output as ordinary page text, and apply suitable sanitization and escaping when rendering it as HTML.

Try it yourself

This example runs in your browser. Change the input and inspect the output.

Open tool · String Tools

Use these tools with this article

  • String Tools

    Transform case, trim outer whitespace, reverse whole graphemes and encode or decode UTF-8 Base64, URL components and HTML entities locally in your browser.

  • Text Reverser

    Reverse text by character, word or line — emoji-safe.

  • HTML Entities

    Convert between HTML entities and characters: named, decimal and hex forms.

  • ASCII Table

    Look up ASCII characters 0–127, decimal, hexadecimal and seven-bit binary codes; choose a literal character or escape and click to copy.

  • Unicode Converter

    Convert text to UTF-16 Unicode escapes and decode four-digit escapes, braced code points and surrogate pairs.

  • Encoder/Decoder

    Online encoding/decoding tool supporting URL encoding, Base64 encoding, HTML entity encoding and multiple format conversions.

Sources