Guide
How Base64 Encoding Works (and When to Use It)
Understand what Base64 is, how it encodes binary as text, and the common use cases and pitfalls.
Base64 encodes binary data as text using a 64-character alphabet, so it can travel through systems that only handle text. A Base64 encoder/decoder converts text or images to a Base64 string and back.
What Base64 is
Base64 maps every 3 bytes of input to 4 characters from a set of 64 (A–Z, a–z, 0–9, +, /, with = for padding). The result is pure text, safe to embed in JSON, HTML, URLs, or email. The trade-off is size: encoded output is about 33% larger than the input.
When to use Base64
- Embedding small images directly in HTML or CSS as data URLs.
- Sending binary data inside a JSON API payload.
- Storing binary in a text-only field or config file.
- Encoding credentials for HTTP Basic auth headers.
How to use an encoder/decoder
- To encode: paste text or upload an image and copy the Base64 string.
- To decode: paste a Base64 string and read the original text or image.
- For URLs, use the URL-safe variant that replaces + and / with - and _.
Examples
The text "Hello" encodes to "SGVsbG8=". A small PNG can be embedded as <img src="data:image/png;base64,iVBORw..."> so the page loads with no separate image request. Decoding "SGVsbG8=" returns "Hello".
Common pitfalls
Base64 is encoding, not encryption — it is trivially reversible, so never use it to protect secrets. The 33% size overhead matters for large files, and some systems choke on line breaks in long Base64 strings. Use URL-safe Base64 where + and / would cause problems.
Put it into practice
Use the Base64 Encoder / Decoder right now — free, in your browser, no sign-up required.
Try the Base64 Encoder / DecoderMore guides
- How to Unscramble Letters Into Words
- How to Find Anagrams of Any Word
- How to Count Words, Characters and Reading Time Accurately
- How to Find Words by Pattern, Length and Letters
- How to Use a Random Word Generator for Games, Writing and Brainstorming
- How to Count Characters (With and Without Spaces)
- How to Convert Text Between Cases (UPPER, lower, Title, camelCase and More)
- How to Clean Up Messy Text (Spaces, Line Breaks and Whitespace)
Related free tools
More free online utilities that pair well with this one — same-category tools for the same task, plus handy extras from other categories.
More developer & security tools
You might also need
- Base64 Image Encoder / DecoderConvert images to Base64 & Base64 back to images
- Case ConverterConvert text to upper, lower, title & more
- Image Format ConverterConvert PNG ↔ JPG ↔ WebP & SVG to PNG
- Image Resizer & CropperResize & crop images to any dimensions
- Text ReverserReverse text, words or characters