6 TOOLS TO EXPLORE

Text encoding in Developer tools

Browse text encoding in developer tools, page 1 of 1. This page includes Base64 Encoder Decoder; Base64Url Encoder Decoder.

Browse 2 subcategories

Six tools that share one idea

All six tools in this topic move text between representations. The Base64 Encoder Decoder and the Base64Url Encoder Decoder turn bytes into letters and digits and back. The Url Encoder Decoder escapes characters that have a special meaning in web addresses. The Unicode Converter shows characters as code points, the Utf8 Byte Converter shows the bytes behind them, and the Utf8 Byte Length Calculator counts those bytes. A useful way to choose is by question: do I need to hide special characters (URL or Base64), see numbers behind characters (Unicode or UTF-8), or measure size (byte length)?

Unicode code points

Unicode assigns a number, called a code point, to each character, written in hexadecimal with a U+ prefix. Capital A is U+0041, the euro sign is U+20AC and the grinning face emoji is U+1F600. The standard allows values up to U+10FFFF, which is 1,114,112 possible code points, although only some are assigned. Some visible characters are built from several code points, such as a letter plus a combining accent, so counting code points does not always match what a reader counts as characters. The Unicode Converter is the tool to use when you need the number behind a symbol.

UTF-8 byte patterns

UTF-8 stores each code point in one to four bytes. Code points up to U+007F use one byte identical to ASCII, up to U+07FF use two, up to U+FFFF use three, and the rest use four. The lead byte signals the length: a byte starting with binary 110 begins a two-byte sequence, 1110 begins three, and 11110 begins four, with continuation bytes beginning 10. That design makes UTF-8 self-synchronizing and backward compatible with ASCII. The euro sign U+20AC becomes E2 82 AC. The Utf8 Byte Converter displays this mapping, which is useful when debugging garbled text.

Why byte length differs from character count

A string of 10 ASCII letters occupies 10 bytes, but 10 Cyrillic letters occupy 20 and 10 Chinese characters occupy 30. Emoji take 4 bytes each, and some emoji sequences join several code points. A database column defined as 100 bytes can hold 100 English letters but fewer than 34 characters in many Asian scripts. The Utf8 Byte Length Calculator gives the figure that matters for storage limits, HTTP header limits and message sizes. Programming languages report string length in different ways, such as UTF-16 code units, which can disagree with the byte count.

Percent-encoding for web addresses

RFC 3986 reserves characters like question mark, ampersand, equals sign and hash for structural roles in a URL. If your data contains one of these, you encode it as a percent sign followed by its hexadecimal byte value. A space is %20, an ampersand is %26 and a plus sign is %2B. Non-ASCII text is first turned into UTF-8 bytes, so each byte is encoded separately: the letter é becomes %C3%A9. Encode each value separately before joining them into a query string. Encoding a whole URL at once also encodes the slashes and colons that must remain.

Base64 and why it exists

Some channels, such as email bodies, JSON fields and URLs, are designed for text and can corrupt arbitrary bytes. Base64, specified in RFC 4648, maps every 3 bytes onto 4 characters from a 64-symbol alphabet, so binary data can travel as text at a cost of about 33 percent in size. The equals sign pads the end when the input length is not a multiple of 3. For example, the three letters Man encode as TWFu. The result is not secret, since any decoder reverses it, so treat Base64 text as readable by everyone who sees it.

The URL-safe alphabet

Standard Base64 uses plus and slash, which have special meanings in URLs. The base64url form in RFC 4648 uses hyphen and underscore instead, and commonly drops the trailing equals signs. JSON Web Tokens, many OAuth parameters and filenames derived from hashes use this form. A common failure is pasting base64url text into a standard decoder, or the reverse, which fails or corrupts data when the text contains the characters that differ. If decoding reports an invalid character, check for hyphens and underscores, and use the Base64Url Encoder Decoder in that case. Match the question to the page. If a service rejects your text for being too long, use the Utf8 Byte Length Calculator, because many limits count bytes. If a link breaks on a special character, use the Url Encoder Decoder on the value, not on the whole address. If binary content must travel inside text, use the Base64 Encoder Decoder, or the Base64Url Encoder Decoder when it will live in a URL. If a symbol looks wrong, check its code point with the Unicode Converter and its bytes with the Utf8 Byte Converter. Starting from the symptom and picking the narrowest tool saves time compared with trying each page in turn.

Frequent mistakes

Double encoding is the most common. Passing a value that is already percent-encoded through an encoder turns %20 into %2520. Another is decoding with the wrong character set, which shows up as strings such as é where é should appear. Plus signs in query strings mean a space in HTML form encoding, but a literal plus elsewhere. Line breaks inside Base64 are allowed in email formats but may be unwelcome in JSON. Copying text from a rich text editor can bring invisible characters such as zero-width spaces or non-breaking spaces, which change byte counts without being visible. Byte order marks are a related trap: some Windows tools put the three bytes EF BB BF at the start of a UTF-8 file, and a parser that does not expect them may report an unexpected character before the first real one. Normalization adds another wrinkle, since é can be one code point (U+00E9) or e followed by a combining accent (U+0065 U+0301), and the two look identical while comparing as different strings.

Using these tools safely

Encoded text is not protected text. If you are working with credentials, tokens or personal data, avoid pasting them into any web page you do not control. The tools show how text is represented, and cannot verify that a token is valid, that a signature matches or that a URL is safe to open. For production code, use your language's standard library for encoding and decoding, and use these pages to inspect examples, check expected output and understand what a library is doing.

Frequently asked questions

How many bytes does the euro sign take in UTF-8?
Three bytes: E2 82 AC. The code point is U+20AC.
Why does my URL show %2520?
The value was percent-encoded twice. The first pass turned a space into %20, and the second turned the percent sign into %25.
Can I decode Base64url with a standard Base64 decoder?
Only if the text has no hyphens or underscores and the padding is restored. Otherwise use a decoder for the URL-safe alphabet.
Is character count the same as byte length?
No. In UTF-8 an ASCII character is one byte, but other characters take two to four bytes, so byte length is often larger.

Explore related formulas, units and constants →