Browser-based developer utility
Encode, decode, inspect

Base64 Encoder & Decoder
for focused browser work

Convert UTF-8 text, inspect Base64URL values, and read a selected local file as a data URI. Copy or download the result after checking the format your system expects.

UTF-8 text conversion
Base64URL decoding
Local file data URIs
Copy and download output
Toolyfi Base64 encoder workspace with encoded data, file conversion, and developer notes Toolyfi

🔐 Base64 Encoder / Decoder — Free Online Tool

⚡ Instant
🖼️ Images & Files
🔒 Runs in your browser
🌐 No Signup
📝 Encode Text 🔓 Decode String 🔑 Decode JWT 🖼️ Encode Image
📤

Drop image or file here to encode to Base64

or click to browse — PNG, JPG, SVG, PDF, TXT and more
Decoded image preview
UTF-8
Text round trips
URL
Safe Base64 variant
Data URI
Local file output
Encode and decode

More than just a Base64 encoder

Choose the input that matches the task: UTF-8 text, a Base64 or Base64URL value, or a selected local file. The page makes the current output easier to copy, inspect, or download.

🖼️

Image to Base64 Data URI

Select a supported image and keep its data URI available for a focused HTML, CSS, JSON, or test-fixture workflow.

🔑

JWT Payload Reader

Decode the Base64URL payload of a JWT to inspect readable fields; decoding does not verify its signature or trustworthiness.

📄

File Support

Encode PDFs, text files, JSON, SVG and more. Drag and drop any file directly onto the tool.

👁️

Live Image Preview

When you decode an image Base64 string, it renders as a visual preview instantly — no extra steps.

🔒

Browser API Conversion

The converter uses browser APIs for selected text or files. Treat credentials, tokens, and personal records as sensitive regardless of encoding.

Input Text
Hello, Toolyfi!
↓ Encode
Base64 Encoded Output
SGVsbG8sIFRvb2x5Zmkh
↓ Decode
Decoded Back to Text
Hello, Toolyfi!
Features

Everything you need in
one free online tool

Built for developers, designers, and anyone who works with Base64 encoding and decoding daily.

Instant Browser-Side Encoding

Select Encode or Decode to run the requested conversion with the browser APIs available on the page.

🖼️

Image to Base64 Data URI

Upload any image and get a complete data URI ready to drop directly into your HTML img tag or CSS background-image property.

🔓

Two-Way Conversion

Encode UTF-8 text or a selected file data URI, then decode compatible Base64 text or show a preview for supported image bytes.

🔑

JWT Payload Reader

Decode a JWT header or payload for a readable format check. This does not validate the signature or authorize token use.

📱

Works on All Devices

The page adapts its editor and controls for narrower and wider browser windows, while the final integration should still be tested in its target environment.

🔒

Clear security boundary

Base64 is reversible encoding, not encryption. Avoid using a browser conversion workflow to expose credentials, private records, or production tokens.

Choose the right format

A Base64 conversion is not a security feature

Use standard Base64, Base64URL, or a data URI only when the receiving system specifies it. Encoding changes representation; encryption protects confidentiality; compression reduces file size.

Need Use Important note
Text-safe transport Standard Base64 Preserve the expected character encoding.
URL or token segment Base64URL Use the URL-safe alphabet and required padding rules.
Small embedded asset Data URI Check the larger encoded size before inlining.
Keep a secret secret Encryption or secure secret storage Base64 is reversible and is not appropriate.

Who uses a free
Base64 encoder online?

From web developers to security researchers — Base64 encoding and decoding solves real problems across many fields.

👨‍💻

Web Developers

Use a data URI when an implementation specifically benefits from a small embedded asset, then compare the encoded size with a separately served file.

📧

Email Developers

Encode images and attachments for email templates where external image links are often blocked by email clients like Outlook and Gmail.

🔌

API & Backend Devs

Encode binary payloads for JSON REST APIs, transmit files over text-based protocols, and inspect Base64-encoded auth tokens.

🎨

UI/UX Designers

Quickly generate inline SVG or image data URIs for Figma prototypes and design systems without needing separate asset hosting.

🔐

Security Researchers

Analyze Base64-encoded payloads in HTTP headers, JWT tokens, and encoded scripts during security audits and penetration testing.

📚

Students & Learners

Understand how Base64 encoding works hands-on — great for computer science courses and web development bootcamps.

Frequently asked questions

Everything you need to know about Base64 encoding and decoding online.

Base64 represents bytes with printable text characters. It helps text-based systems carry binary values, but it does not make information secret.
Paste text into the input field and choose Encode to Base64. Copy or download the output after checking it in the system that will consume it.
Yes. Text conversion uses browser TextEncoder and TextDecoder APIs, which preserve ordinary UTF-8 text including accents and emoji when decoded as UTF-8.
Yes. The decoder accepts Base64URL characters and restores standard padding before decoding. Use the format required by the receiving system.
Yes. Select a local file and the page reads it with the browser FileReader API as a data URI. The converter does not upload the file.
No. Base64 is reversible encoding, not encryption or access control. Do not use it to protect passwords, API keys, or private records.
Equals signs are padding used when the source byte length is not a multiple of three. Some Base64URL systems omit padding, so follow the target specification.
When decoded bytes match a supported image format, the page shows an in-browser image preview. Unknown or other binary content needs an appropriate file-aware workflow.
Yes. After a conversion, select Download Output to save the text result as a local text file.
Base64 represents each three bytes as four text characters, so the encoded output is usually roughly one third larger before any surrounding format overhead.

Base64 Encoder & Decoder — practical browser guide

If you have worked with web development, REST APIs, or data transmission, you have almost certainly encountered Base64 encoding. It is one of the most widely used encoding schemes on the internet — used in everything from embedding images in CSS to decoding JWT authentication tokens.

This guide explains what Base64 changes, where standard and URL-safe forms differ, how local file data URIs behave, and which boundaries a converter cannot provide.

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme. It converts binary data — bytes that may include any value from 0 to 255 — into a string of printable ASCII characters. The "64" in Base64 refers to the 64 characters used: A–Z, a–z, 0–9, plus (+), and slash (/).

The reason Base64 exists is simple: many text-based systems cannot handle raw binary data. Email protocols, HTTP headers, JSON payloads, and XML files were all designed to carry 7-bit ASCII text. When you need to include binary content — like an image, a PDF, or a compiled file — in one of these systems, you need to convert it to safe text first. That is exactly what Base64 encoding does.

💡 Base64 is encoding, not encryption. It is easily reversible by anyone. Never use it to protect sensitive data like passwords or API keys.

How Does Base64 Encoding Work?

The encoding process takes three bytes (24 bits) of binary data at a time and converts them into four Base64 characters (each representing 6 bits). Here is the step-by-step process:

  1. Take the binary data and group it into 3-byte (24-bit) chunks.
  2. Split each 24-bit group into four 6-bit groups.
  3. Map each 6-bit value (0–63) to the corresponding Base64 character in the alphabet table.
  4. If the input length is not a multiple of 3, padding characters (=) are appended.

For example, the ASCII string "Hello, World!" encodes to:

Text: Hello, World! Base64: SGVsbG8sIFdvcmxkIQ==

7 Most Common Uses of Base64 Encoding

1. Embedding Images in HTML and CSS (Data URIs)

One of the most practical uses for web developers is embedding small images directly in HTML or CSS as Base64 data URIs. Instead of linking to an external file, you include the image inline:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."> /* CSS */ background-image: url('data:image/svg+xml;base64,PHN2ZyB4...');

Inlining avoids a separate resource request, but it also increases the transferred page or stylesheet size. Compare the encoded result with the delivery requirements of the page instead of relying on a fixed universal threshold.

2. Email Attachments (MIME Encoding)

SMTP — the protocol that powers email — was designed for 7-bit ASCII text. Binary attachments like PDFs, images, and Word documents cannot be sent directly. The MIME standard uses Base64 to encode these attachments into ASCII text for transmission. Your email client (Gmail, Outlook, Apple Mail) automatically decodes them on the receiving end.

3. REST API JSON Responses

JSON is a text format. When a REST API needs to return binary data — like a generated PDF, a thumbnail image, or audio data — the server encodes it as Base64 and includes it in the JSON response. The client then decodes it to get the original binary file.

4. JWT Authentication Tokens

If you have worked with authentication in modern web apps, you have used Base64 without knowing it. JWT (JSON Web Tokens) are three Base64URL-encoded sections separated by dots: the header, payload, and signature. Paste any JWT into the decoder above to read its contents.

5. Basic HTTP Authentication

HTTP Basic Authentication sends credentials in the Authorization header as Base64-encoded username:password. For example, username "admin" and password "secret" becomes: Authorization: Basic YWRtaW46c2VjcmV0. Note this is NOT secure — use HTTPS always.

6. Storing Binary Data in Databases

Some database systems and ORMs store binary blobs as Base64 strings in text columns. This simplifies queries and avoids binary handling issues — though it does increase storage size by 33%.

7. Configuration Files and Environment Variables

Service account keys, SSL certificates, and API credentials are often Base64-encoded for inclusion in environment variables and config files — since these text formats cannot handle newlines or binary characters in raw form.

Base64 vs Base64URL — Key Difference

Standard Base64 uses + and / characters, which have special meaning in URLs (+ means space, / separates path segments). This causes problems when Base64 strings appear in query parameters or URL path segments.

Base64URL solves this by replacing + with - and / with _. It also omits the padding = signs. JWT tokens use Base64URL encoding for this reason. If you are decoding a JWT or URL-safe Base64 string on Toolyfi, replace - with + and _ with / before decoding.

How to Encode an Image to Base64 — Step by Step

  1. Open Toolyfi's free Base64 encoder at the top of this page.
  2. Drag and drop your image onto the upload area, or click to browse files.
  3. The image will load and show a preview.
  4. Click "Encode to Base64."
  5. The Output box contains the full data URI: data:image/png;base64,...
  6. Click Copy and paste it into your HTML img tag or CSS stylesheet.

💡 For CSS: background-image: url('data:image/png;base64,...');  |  For HTML: <img src="data:image/png;base64,...">

How to Decode a JWT Token Using Base64

  1. Copy your full JWT token (looks like: xxxxx.yyyyy.zzzzz).
  2. The middle section (yyyyy) is the Base64URL-encoded payload.
  3. Copy just the middle section between the two dots.
  4. If it contains - or _, replace with + and / respectively.
  5. Paste into the Input box above and click "Decode from Base64."
  6. The JSON payload with claims (user ID, expiry, roles) appears in Output.

Base64 Encoding in Popular Programming Languages

JavaScript / Node.js

// Browser — Encode const encoded = btoa('Hello, World!'); // Result: 'SGVsbG8sIFdvcmxkIQ==' // Browser — Decode const decoded = atob('SGVsbG8sIFdvcmxkIQ=='); // Node.js — Encode const encoded = Buffer.from('Hello, World!').toString('base64'); // Node.js — Decode const decoded = Buffer.from('SGVsbG8sIFdvcmxkIQ==', 'base64').toString();

Python

import base64 # Encode encoded = base64.b64encode(b'Hello, World!').decode('utf-8') # Result: 'SGVsbG8sIFdvcmxkIQ==' # Decode decoded = base64.b64decode('SGVsbG8sIFdvcmxkIQ==').decode('utf-8')

PHP

<?php // Encode $encoded = base64_encode('Hello, World!'); // Decode $decoded = base64_decode('SGVsbG8sIFdvcmxkIQ=='); ?>

Bash / Linux Command Line

# Encode echo -n 'Hello, World!' | base64 # Output: SGVsbG8sIFdvcmxkIQ== # Decode echo 'SGVsbG8sIFdvcmxkIQ==' | base64 --decode

Limitations of Base64 Encoding

Why Use an Online Base64 Encoder Instead of the Command Line?

For developers comfortable with the terminal, base64 command-line tools work great. But online tools like Toolyfi offer several advantages: no installation required, visual image preview when decoding, drag-and-drop file support, and one-click copy. They are especially useful for quick checks, debugging, and sharing with team members who are not comfortable with command-line tools.

Local browser processing

Toolyfi's Base64 encoder and decoder runs entirely in your browser using JavaScript's built-in btoa() and atob() functions, plus the FileReader API for file and image uploads.

The conversion functions use browser APIs on the current device. Do not paste secrets or sensitive records into a troubleshooting workflow; Base64 itself does not provide confidentiality.

Related Free Tools on Toolyfi

Conclusion

Base64 is useful in web development, backend engineering, and API integration when a system expects an ASCII-safe representation of bytes. This tool offers a focused browser workspace for examining text, Base64URL values, and local file data URIs.

Try it now — paste any text or upload any image above and see the Base64 result in milliseconds. No account needed, ever.

Working with Base64 safely in a browser

A Base64 converter is useful because it changes representation, not because it protects information. The browser tool above can encode ordinary UTF-8 text, turn a local file into a data URI, and decode a Base64 or Base64URL value into readable text when that is the value’s actual content. It performs those operations in the page on your device. That local workflow is convenient for a focused technical task, but it should not be confused with encryption, file validation, malware scanning, or a permanent storage service.

Before pasting a value, decide what you expect it to represent. A short Base64 string may be plain text, a JSON document, a Base64URL fragment, or binary data such as an image. A long string may be a file payload. If it is a JSON web token, its header and payload can be decoded for inspection, but the signature is not decoded as readable text and decoding it does not prove that the token is trusted, current, or safe to use.

Encode UTF-8 text without breaking emojis

Web pages work with Unicode text, while Base64 operates on bytes. A converter that only uses an ASCII shortcut can fail on names, accents, Urdu, Arabic, Chinese, or emoji. Toolyfi first converts text with UTF-8 so that characters such as café, , and 👋 can make a normal encode–decode round trip. This does not mean every external system will interpret the decoded bytes in the same character set; when an API specifies a charset, follow that API’s documentation.

For a simple check, type a short line containing the characters you actually need, click Encode, then paste the result back into the input and click Decode. Compare the result character by character. This small round-trip test is more reliable than assuming that an encoded value is correct because it “looks like Base64.”

Standard Base64 versus Base64URL

Standard Base64 uses + and /, with optional = padding at the end. Base64URL is a related form intended for URL and filename contexts: it substitutes - for + and _ for /, and many implementations omit trailing padding. The decoder above accepts those URL-safe characters, restores required padding, and then decodes the result as UTF-8 when possible.

Do not convert a value to Base64URL unless the receiving system asks for it. A standard Base64 string in an API request and a Base64URL string inside a token are not interchangeable merely because both use a similar alphabet. Keep the original specification close to the code or configuration that consumes the value.

Use file and image data URIs deliberately

When you select a local file, the tool reads it in the browser and creates a data URI. A data URI contains both a media type and Base64 data, such as data:image/png;base64,.... This format is useful when a small asset truly needs to travel inside an HTML document, stylesheet, JSON payload, test fixture, or API field. The output can be copied as a full data URI or, if an integration asks for it, as the Base64 part after the comma.

Inlining has a cost. Base64 generally adds roughly one third to the raw byte count, and embedding a large image makes an HTML or CSS file harder to cache, inspect, and update. Use small, stable assets only when the surrounding delivery mechanism benefits from it. For ordinary website images, a separately optimized file is often simpler. Toolyfi’s Image Compressor and Image Resizer can help prepare those files before you decide how to deliver them.

Decode unknown content with realistic expectations

Base64 decoding reconstructs bytes. It does not automatically identify every file type, guarantee that the content is safe, or make a binary file readable as text. If a value is an image data URI, the page can show an image preview in the browser. If it is text, it appears in the output. If it represents a binary file, download or inspection decisions should be made carefully and only with content from a source you trust.

Never treat Base64 as a security boundary. Anyone who receives an encoded secret can decode it. Keep credentials, private keys, personal records, access tokens, and production configuration out of screenshots, chat messages, shared links, or public paste sites.

Inspect JWTs without over-trusting them

A JSON Web Token commonly has three dot-separated segments: a header, a payload, and a signature. The first two segments are usually Base64URL-encoded JSON. Decoding them can help a developer identify fields such as an expiry timestamp, issuer, audience, or role while debugging a local application. It does not verify the signature, it does not authenticate the holder, and it does not establish that a token’s claims are true.

For a safe inspection workflow, work with a redacted test token whenever possible. Read the fields, check the expected issuer and audience in your application configuration, and use the server-side library for signature validation. If you find a real production token in a log or message, treat it as sensitive and follow your organisation’s incident process rather than pasting it into a browser tool.

Common Base64 errors and how to resolve them

“Invalid character” or “not correctly encoded”

Remove surrounding quotes, labels such as base64:, and whitespace that is not part of the value. If the string is URL-safe, use the - and _ form directly; the tool normalises it before decoding. If the value includes a data URI prefix, keep it intact or remove everything through the first comma. A value copied from a wrapped email message may also have line breaks that need to be removed.

Decoded text looks garbled

The bytes may not be UTF-8 text. They could be a file, an image, compressed data, encrypted data, or text encoded in a different character set. Confirm the source format before guessing. Base64 is only one layer of a data format; decoding it correctly does not tell you what the underlying bytes mean.

The data URI is too large

Check the original file size and choose a more appropriate delivery method. A compressed or resized image may be suitable, while a document or video should normally stay as a file. If the receiving field has a documented size limit, use that limit rather than an arbitrary guideline.

Practical developer workflows

For an API test, encode a known small text fixture, send it only to an approved test endpoint, and decode the returned payload to confirm the expected round trip. For an HTML prototype, encode a small icon as a data URI, paste it into the exact attribute or CSS property that will consume it, and check the rendered output in the HTML Preview Tool. For structured data, use the JSON Formatter before copying a Base64 field into JSON so that missing commas or quotation marks do not hide the real problem.

For text clean-up, use the Text Trimmer to remove accidental spaces and line breaks before encoding, or the Case Converter when a value’s surrounding identifier needs a consistent case style. These utilities solve different problems: Base64 changes bytes into an ASCII-safe representation; it does not trim text, validate JSON, compress a file, or encrypt a secret.

A simple pre-share checklist

  1. Confirm whether the target expects standard Base64, Base64URL, a data URI, or a raw file.
  2. Use a short, non-sensitive sample first and round-trip it through the intended system.
  3. Remove logs, headers, credentials, and personal data before sharing a troubleshooting sample.
  4. For an image, compare its original size with the longer encoded output before embedding it.
  5. Document the media type, character set, and any padding rule next to the consuming code.

Conclusion

Base64 is a dependable transport encoding when you use the expected variant, preserve character encoding, and understand the cost of converting bytes to text. Toolyfi provides a quick browser-side workspace for text, Base64URL, local file data URIs, and simple image previews. Use it to make a specific conversion easy to inspect, then test the final value in the system that will actually consume it.

Base64 conversion workflow for teams

When a Base64 value is part of a bug report or a handoff, include only the minimum reproducible sample. State whether the value is standard Base64 or Base64URL, whether it has a data URI prefix, and what the recipient should expect after decoding. If the example is an image, include its original file type and dimensions. If it is text, include the intended character set. These details prevent a reviewer from spending time guessing at a representation problem.

Keep encoded values out of commit messages, issue titles, screenshots, and public chat rooms when they contain information that should remain private. Encoding can make a value less readable at a glance, but it does not reduce its sensitivity. Use redacted fixtures for documentation and test data, and use the secure secret-management path approved by the project for real credentials.

When not to use Base64

Do not choose Base64 because it seems like a shortcut for file hosting, access control, compression, or encryption. It makes files larger, has no built-in integrity check, and anyone can reverse it. A separately served image can be cached; a compressed archive can reduce size; a cryptographic hash can detect changes; and authenticated encryption can protect confidentiality. The correct choice depends on the system’s real requirement, not on what is easiest to paste into one text field.

Use this page for clear, local conversion work and use the receiving platform’s documentation for the final format. That approach keeps technical samples understandable, avoids accidental exposure of information, and makes a Base64 value easier to maintain over time.

Keep the original data and context

Encoding is most useful when the original file, text, and purpose remain clear. Retain the source asset or source string in its appropriate project location rather than treating the Base64 output as the only copy. Name any generated values clearly, record the expected media type, and avoid hand-editing long encoded strings. When a value fails later, compare it with a newly generated result from the original source. This simple practice makes troubleshooting faster and reduces the risk of silently corrupting a payload while it is moved between a browser, a code editor, and an API client.

Need a related developer utility?

Use the Toolyfi directory to move from a Base64 conversion to the next focused formatting, preview, or text-preparation task.

Explore all tools