DevToolBoxFREE
Blog

String to Base64 Converter

Convert any string to Base64 encoding with full UTF-8 support. Get both standard Base64 and URL-safe Base64 output simultaneously.

Convert any string to base64 encoding with full UTF-8 support. This string to base64 converter handles multi-byte characters including CJK (Chinese, Japanese, Korean), emojis, accented characters, and all Unicode text. Get both standard and URL-safe base64 output. URL-safe Base64 replaces + with -, / with _, and removes = padding for safe use in URLs and file names.

0 characters / 0 bytes

UTF-8 Encoding in Base64

When converting strings to Base64, the text is first encoded as UTF-8 bytes, then those bytes are encoded to Base64. Multi-byte characters produce longer Base64 output.

CharacterUTF-8 BytesBase64B64 Length
A1 byte (0x41)QQ==4
e2 bytes (0xC3 0xA9)w6k=4
δΈ–3 bytes (0xE4 0xB8 0x96)5LiW4
πŸ˜€4 bytes (0xF0 0x9F 0x98 0x80)8J+YgA==8

Standard vs URL-Safe Base64

StandardURL-Safe
CharactersUses + / =Uses - _ (no padding)
Use CasesMIME, email, general encodingURLs, file names, JWT tokens

FAQ

How does UTF-8 affect Base64 encoding?
UTF-8 is a variable-length encoding: ASCII characters use 1 byte, accented characters use 2 bytes, CJK characters use 3 bytes, and emojis use 4 bytes. This means the same number of characters can produce very different Base64 output lengths. For example, "Hello" (5 ASCII chars = 5 bytes) encodes to 8 Base64 characters, while 5 Chinese characters (15 bytes) encode to 20 Base64 characters.
What is URL-safe Base64?
URL-safe Base64 (also called base64url) modifies the standard Base64 alphabet to be safe for use in URLs and filenames. It replaces + with - (hyphen), / with _ (underscore), and removes the = padding characters. This variant is defined in RFC 4648 Section 5 and is commonly used in JWT (JSON Web Tokens), OAuth, and URL parameters.
How do different programming languages encode strings to Base64?
In JavaScript, use btoa(unescape(encodeURIComponent(str))) for UTF-8 support. In Python, use base64.b64encode(str.encode("utf-8")). In Java, use Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8)). In Go, use base64.StdEncoding.EncodeToString([]byte(str)). All these methods first convert the string to UTF-8 bytes, then encode those bytes to Base64.
𝕏 Twitterin LinkedIn

Rate this tool

3.6 / 5 Β· 92 ratings

Stay Updated

Get weekly dev tips and new tool announcements.

No spam. Unsubscribe anytime.

Enjoy these free tools?

β˜•Buy Me a Coffee