Base64 Encoder/Decoder
Variant
Input0 B
Output0 B

Base64 Encode & Decode Online Free — Text, Files & Images

Updated May 14, 2026
Share & Support

What's included

Features

Live Base64 text encoding and decoding — output updates instantly as you type
Standard, URL-safe Base64URL (JWT tokens), and MIME (76-char line breaks) variant support
File and image encoding — drag & drop or upload any file and encode its bytes to Base64; compress the image first with our Image Compressor
Automatic image preview — when decoding a Base64 image (PNG, JPEG, GIF, WebP, SVG), a live preview is shown
Data URI output — toggle to wrap encoded output as data:mime/type;base64,... for HTML/CSS use; convert images directly with our Image to Base64 converter
Swap button — flips output back to input and switches encode/decode mode in one click
Byte counter — shows input and output sizes and the size change percentage
One-click copy to clipboard and file download for encoded or decoded output
100% client-side — uses native browser btoa(), atob(), TextEncoder/TextDecoder APIs; encode URLs with our URL Encoder / Decoder
No signup, no file size limit, works offline once the page has loaded

About this tool

Base64 Encoder & Decoder — Encode Text, Files, and Images Instantly

Runs in your browser
No install or signup
Free forever

You need to encode a string to Base64 for an Authorization header. Or you got a Base64 blob from an API response and need to read what's inside. Or you're trying to decode a JWT token's payload without installing anything. This free online Base64 encoder and decoder handles all three — paste any text or Base64 string and the output is instant, right in your browser.

Base64 is a binary-to-text encoding that converts any data into a string of 64 safe printable characters. It exists because binary data — image bytes, file bytes, arbitrary byte sequences — can't safely travel through text-only channels like JSON, email headers, HTML attributes, and HTTP headers. Those channels may corrupt or strip certain byte values. Base64 solves this by encoding every 3 input bytes into exactly 4 printable characters, so the output is safe anywhere text is allowed.

Which variant do you need? Standard Base64 is the default — used for HTTP headers, general encoding, and most APIs. Base64URL replaces + with - and / with _ and drops the = padding — this is the variant used inside JWT tokens, because + and / are special characters in URLs. MIME Base64 adds a line break every 76 characters — that's the format for email attachment encoding.

Data URIs: When encoding an image or file, enable the Data URI toggle to wrap the output in data:image/png;base64,... format. Paste that directly into an HTML <img src=""> or CSS background-image: url() and the browser renders the image without any network request — no server needed.

Important: Base64 is encoding, not encryption. Anyone can decode it in one line of code with no key. Never use it to hide passwords, API secrets, or sensitive data. For security, use proper encryption. For JWT tokens specifically, the security comes from the digital signature — not from the Base64URL encoding of the header and payload.

Everything in this tool runs 100% in your browser. Nothing is uploaded to a server. Safe for API keys, certificate data, or any content you wouldn't want sent to a third-party service.

Step by step

How to Use

  1. 1
    Choose Encode or Decode modeUse the Encode / Decode toggle at the top of the tool to select which direction you want to convert. Encode turns plain text or file bytes into a Base64 string. Decode turns a Base64 string back into readable text or an image.
  2. 2
    Select the right Base64 variantChoose Standard (RFC 4648) for most uses — HTTP headers, API payloads, and general encoding. Choose Base64URL when encoding values that will appear in URLs, JWT tokens, or filenames — it replaces + with - and / with _ and removes = padding. Choose MIME for email attachments that require a line break every 76 characters.
  3. 3
    Input text, paste Base64, or upload a fileIn Encode mode, type or paste your text into the input pane — the Base64 output appears instantly on the right as you type. To encode a file or image, click File or drag and drop any file onto the input area. In Decode mode, paste a Base64 string and the decoded text appears immediately. If the decoded content is an image (PNG, JPEG, GIF, WebP, SVG), a live preview is shown above the text output.
  4. 4
    Enable Data URI for HTML and CSS use (optional)When encoding an image or file in Encode mode, toggle Data URI on. The output is wrapped in data:mime/type;base64,... format automatically — paste it directly into an HTML <img src=""> attribute or a CSS background-image: url() to render the image with no network request. Most useful for small icons, email templates, and offline-first apps.
  5. 5
    Copy, download, or swap the outputClick Copy to copy the full output to your clipboard, or the Download icon to save it as a file. Use the ⇄ swap button to send the current output back to the input and flip modes — useful for round-trip verification (encode, then swap and decode to confirm you get the original text back). The byte counter shows input and output sizes and the size change — Base64 output is always approximately 33% larger than the input.

Real-world uses

Common Use Cases

🔑
Decode a JWT token header or payload without a library
A JWT is three Base64URL-encoded segments separated by dots. Select Base64URL variant, paste the header or payload segment (the first or second part before and after the first dot), and click Decode. You get the raw JSON with the algorithm, claims, expiry, issuer, and audience — no library, no install, no server. For a dedicated JWT tool, use our JWT Decoder.
🖼
Encode an image as a Data URI for HTML or CSS
Upload a small PNG, SVG, GIF, or WebP icon, enable the Data URI toggle, and copy the output directly into an HTML <img src=""> attribute or a CSS background-image: url() value. The browser renders the image instantly with no network request — useful for email templates where external images are blocked, and for small icons in offline-first apps.
🔐
Build an HTTP Basic Auth header from a username and password
HTTP Basic Authentication requires a header in the format Authorization: Basic [base64("username:password")]. Type your username:password string in Standard mode, encode it, and prepend "Basic " to the result. Use Standard (not Base64URL) — Basic Auth uses RFC 4648 Standard encoding.
📧
Encode an email attachment in MIME Base64 format
MIME multipart email messages require file attachments encoded in MIME Base64 with a line break every 76 characters. Upload or paste your file content, select the MIME variant, and the output will conform to RFC 2045 line length requirements accepted by email servers.
📦
Encode binary data for JSON API payloads
JSON cannot represent raw binary values. When an API field contains image bytes, cryptographic keys, file data, or certificate content, it must be Base64-encoded first. Encode any binary content here and paste the result string directly into your JSON request body or response.
🎨
Embed a web font or SVG pattern as a CSS Data URI
Small WOFF, WOFF2, and SVG files can be embedded in a CSS @font-face src declaration or background-image URL as Base64 Data URIs — eliminating the extra font file request for custom icon fonts or decorative patterns.

Got questions?

Frequently Asked Questions

Select Encode mode (the toggle at the top), paste or type your text in the input panel, and the Base64 output appears instantly on the right. No button click needed — it updates live as you type. Choose Standard Base64 for most uses. If you need the output to be safe in a URL or JWT token, select Base64URL instead.

Select Decode mode, paste your Base64 string into the input panel, and the decoded text appears instantly. If the Base64 string is from a JWT token, select the Base64URL variant — JWT uses Base64URL (with - and _ instead of + and /) rather than Standard Base64. If the decoded result is an image, a live preview is shown below the text output.

No — Base64 is encoding, not encryption. It is completely reversible with no key or password. Anyone can decode a Base64 string in one line of code in milliseconds. The scrambled-looking output is not security — it is just a different text representation of the same data. Never Base64-encode passwords, API secrets, or sensitive data to "hide" them. Use proper encryption (AES-256) or hashing with salts (bcrypt, Argon2) for real security.

A JWT has three parts separated by dots: header.payload.signature. The header and payload are each Base64URL-encoded JSON objects. Select Base64URL variant and Decode mode, then paste the second segment (the payload — between the first and second dots) to read the JSON claims: user ID, role, expiry (exp), issuer (iss), and audience (aud). Note: decoding the payload does not verify the signature — it only reads the claims. The security of a JWT comes from the digital signature, not the encoding.

Standard Base64 uses + and / as the 63rd and 64th characters and adds = padding. These are problematic in URLs: + means space in form-encoded query strings, / is a path separator. Base64URL replaces + with - and / with _ and drops the = padding, making the output safe in URLs, query parameters, and file names. JWT tokens use Base64URL because the token appears in HTTP headers, query parameters, and cookies where + and / would cause parsing issues.

Upload your image file (or drag and drop it onto the input panel), then enable the Data URI toggle. The output will be wrapped in the format data:image/png;base64,... automatically. Paste that entire string into an HTML <img src=""> attribute or a CSS background-image: url() and the browser renders the image without making any network request. This is most useful for small icons, email template images where external URLs are blocked, and offline-first applications.

Base64 uses 4 characters to encode every 3 bytes of input — a 33% size increase. A 100 KB image becomes roughly 133 KB as Base64. For small files (a few KB), this overhead is often worth it to eliminate an extra HTTP request. For larger files, serving them as separate files with proper compression is almost always more efficient than embedding them as Data URIs.

Base64 encodes in 3-byte blocks, producing 4 output characters per block. When the input length is not a multiple of 3, the last block is padded with = characters to complete the group — one = if the last block had 2 bytes, two == if it had 1 byte. Base64URL omits this padding since the decoder can infer it from the string length. This is why JWT token segments have no = signs.

Yes — 100% private. All encoding and decoding runs in your browser using native JavaScript: btoa(), atob(), TextEncoder, TextDecoder, and the FileReader API. Nothing is uploaded to a server. You can safely encode API keys, certificate data, tokens, private user data, and any binary content you would not want sent to a third-party service. The tool also works fully offline once the page has loaded.