Base64 Encoder
Convert any text or file to a Base64-encoded string instantly. Supports standard and URL-safe Base64 (used in JWTs and URLs). Copy output in one click. 100% client-side.
Related Tools
Frequently Asked Questions
What is Base64 encoding used for?▾
Base64 encoding converts binary data into printable ASCII characters so it can be safely transmitted over text-based protocols. It was originally designed for MIME email attachments — embedding binary files (images, PDFs) inside an email message.
Today it appears in data URLs (images embedded in HTML/CSS as data:image/png;base64,...), JWTs (header and payload are Base64url-encoded), JSON payloads (binary fields stored as strings), and OAuth tokens. It is also used in HTTP Basic Authentication (credentials are Base64-encoded in the Authorization header) and in storing binary blobs in databases or config files that expect text.
Does Base64 encoding compress data?▾
No — Base64 actually increases the size of the data by approximately 33%. This happens because it encodes every 3 bytes of binary input into 4 ASCII characters. Three bytes = 24 bits, split into four 6-bit groups, each mapped to one of 64 printable characters.
So a 1 MB file becomes roughly 1.37 MB when Base64-encoded. If you need to reduce size, compress the data first (gzip, deflate), then Base64-encode the compressed bytes.
What is URL-safe Base64?▾
Standard Base64 uses + and / as the 62nd and 63rd characters, and = for padding. These characters have special meaning in URLs: + means space in form encoding, / is a path separator, and = appears in query strings. Embedding standard Base64 in a URL without percent-encoding breaks parsing.
URL-safe Base64 (Base64url) replaces + with - and / with _, and typically omits the = padding. It is used in JWTs, OAuth access tokens, PKCE code challenges, and any context where the encoded value is placed directly in a URL or filename.
How do I encode to Base64 in JavaScript and Python?▾
JavaScript (browser): btoa('hello') for ASCII text. For Unicode strings: btoa(unescape(encodeURIComponent('text'))). In Node.js: Buffer.from('hello').toString('base64'). For URL-safe output: Buffer.from('hello').toString('base64url').
Python: import base64; base64.b64encode(b'hello').decode() for standard Base64. For URL-safe: base64.urlsafe_b64encode(b'hello').decode().
Terminal (macOS/Linux): echo -n 'hello' | base64