What Is Base64 Encoding?
Base64 shows up everywhere: JWTs, data URLs, API payloads, email attachments, and tooling output. Developers often copy/paste Base64 strings without thinking about what they represent. This article explains Base64 clearly and shows when it’s appropriate to use.
What is Base64?
Base64 is an encoding that represents binary data as ASCII characters. It uses 64 symbols (A–Z, a–z, 0–9, plus two additional symbols like + and /) to encode bytes into text. That makes Base64 useful whenever you need to move binary data through systems that expect text: JSON, XML, URLs, or form fields.
Encoding vs encryption (important!)
Base64 is not encryption. Anyone can decode Base64 back into the original bytes. If you need secrecy, you need encryption (or signing) in addition to encoding. Base64 is simply a transport-friendly representation.
When should you use Base64?
- Data URLs: embed small images/icons directly in HTML/CSS.
- API payloads: send binary blobs (like small files) inside JSON when multipart upload isn’t available.
- Email and MIME: attachments and inline content are commonly Base64-encoded.
- Tokens: JWTs use Base64url for header and payload segments (a URL-safe variant).
When you should avoid Base64
Base64 increases size by roughly 33% compared to the original bytes. For large files, it’s usually better to upload the file directly (multipart) and store a URL or reference in your JSON instead of the Base64 itself.
How to encode Base64 in the browser
To encode plain text, you convert the text to bytes and then encode those bytes into a Base64 string. For files, you read the file and encode its bytes. DevToolDock does this client-side so your input isn’t sent to a server.
Use our Base64 Encoder to encode text instantly. If you’re trying to see what a Base64 blob contains, use the Base64 Decoder to reverse it.
Common Base64 pitfalls
- Newlines: some encoders insert line breaks; many decoders can handle them but some can’t.
- Padding: Base64 often ends with
=or==. Removing padding can break strict decoders. - Base64 vs Base64url: JWT uses Base64url which swaps characters and removes padding for URL safety.
Related tools
If you’re dealing with tokens, Base64 often appears inside JWTs. After decoding Base64, you may want to inspect a token with our JWT Decoder. For converting images, try Image to Base64 and Base64 to Image.