Base64 encoder & decoder
Encode text or files to Base64, or decode Base64 back to plain text. Supports standard and URL-safe variants, plus image preview and data URI generation.
Encoding binary as text
Base64 converts binary data (files, images, arbitrary bytes) into a string of 64 ASCII characters. Every 3 bytes of input become 4 characters of output, increasing size by ~33%.
Where you'll encounter it
Email attachments (MIME), embedding images in HTML/CSS as data URIs, encoding binary data in JSON APIs, Basic Auth headers (Authorization: Basic user:pass), and JWT tokens.
Base64URL
Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 replaces them with - and _ and omits the = padding. Used in JWTs and OAuth tokens.
Using Base64 in PHP
base64_encode($str) — encode.base64_decode($str) — decode.
For URL-safe: strtr(base64_encode($s), '+/', '-_')
Our PHP developer ebooks cover real-world patterns including authentication, file processing, and API integration.