Base64 Encoder and Decoder

Encode or decode Base64 strings instantly. Supports plain text, URL-safe Base64, and file encoding. All processing happens in your browser. No data stored.

Input: 0 characters
Output: 0 characters

Quick examples

What is Base64 encoding and when do you need it?

Base64 encoding converts binary data into a string of 64 printable ASCII characters. It is used when binary data needs to travel through systems that only handle text safely. Common uses include embedding images directly in HTML or CSS, sending binary files through JSON APIs, storing binary data in XML, and encoding JWT token payloads.

Base64 is not encryption and provides no security. Anyone can decode a Base64 string instantly. Its only purpose is format compatibility. If you see a long string of random-looking letters and numbers ending in == in an API response, a data URI, or a configuration file, it is almost certainly Base64 encoded data. Paste it into the decoder above to see the original content. If you are dealing with structured API payloads, you can inspect them using our [JSON formatter](/tools/json-formatter).

Standard Base64 vs URL-safe Base64: what is the difference?

Standard Base64 uses the characters + and / which have special meaning in URLs (+ means space, / separates path segments). URL-safe Base64 replaces + with - and / with _ and removes the trailing = padding. This makes the encoded string safe to use directly in URLs, filenames, and HTTP headers without percent-encoding.

JWT tokens use URL-safe Base64 (called Base64url) for exactly this reason. The header and payload sections of a JWT are Base64url encoded so they can appear in Authorization headers and URL parameters without breaking URL parsing. Enable the URL-safe toggle above when encoding data destined for a URL, JWT, or filename. If you need to validate specific URL patterns or headers, you can build matches with our [regex tester](/tools/regex-tester).

How to embed images in HTML using Base64 data URIs

A Base64 data URI embeds an image directly in HTML without a separate file request. The format is: data:[media type];base64,[encoded string]. Use it as the src attribute of an img tag. Upload your image in the File tab above to get the complete data URI ready to paste.

Data URIs are useful for small icons, favicons, and images used in email templates where external image loading may be blocked. The tradeoff is file size: Base64 encoding increases image size by about 33%, and the encoded string cannot be cached separately by the browser. For large images or frequently accessed assets, a standard external URL performs better. Use data URIs for small, inlined assets only. Learn more about file optimization and data sizes in our [JSON formatting guide](/guides/json-formatter-guide-2026), or convert units using our [unit converter](/tools/unit-converter).

Frequently asked questions about Base64 encoding

What is Base64 encoding?

Base64 is an encoding scheme that converts binary data into a text string using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It is used to safely transmit binary data over systems that only handle text, such as email, JSON APIs, and HTML data URIs.

How do I encode text to Base64?

Paste your text into the input field above and click Encode. The tool converts your text to Base64 instantly. In JavaScript you can use btoa("your text") to encode and atob("base64string") to decode. In Python use base64.b64encode(text.encode()).decode().

What is the difference between Base64 and URL-safe Base64?

Standard Base64 uses + and / characters which have special meaning in URLs. URL-safe Base64 replaces + with - and / with _ so the encoded string can be used safely in URLs and filenames without percent-encoding. Enable URL-safe mode above when encoding data for use in a URL or JWT token.

Is Base64 encoding the same as encryption?

No. Base64 is encoding, not encryption. Anyone can decode a Base64 string instantly without a key. It provides no security or confidentiality. Base64 is used for safe data transmission and formatting, not for hiding or protecting information.

Why does Base64 encoded text end with == signs?

Base64 works in groups of 3 bytes. If the input length is not divisible by 3, padding characters (=) are added to make the output a multiple of 4 characters. One = means 1 byte of padding was added, two == means 2 bytes. The padding is required for correct decoding.

How much larger is Base64 encoded data than the original?

Base64 encoding increases data size by approximately 33%. Every 3 bytes of input becomes 4 bytes of Base64 output. A 1 MB file encoded to Base64 becomes approximately 1.37 MB. This size increase is why Base64 is only used when necessary, not as a general-purpose format.

Can I encode images or files to Base64?

Yes. Use the File tab above to upload an image or any file. The tool reads the file in your browser and converts it to a Base64 string. This is commonly used to embed images directly in HTML or CSS as data URIs, or to send binary files through JSON APIs.

How do I use Base64 in a data URI for HTML?

A data URI embeds a file directly in HTML without a separate file request. Format: data:[mediatype];base64,[encoded string]. For a PNG image: data:image/png;base64,[your base64 string]. Paste this as the src attribute of an img tag. The file tab above shows the complete data URI for any file you upload.

What is Base64 used for in JWTs?

JWT (JSON Web Token) uses URL-safe Base64 encoding (called Base64url) to encode the header and payload sections. The three parts of a JWT are separated by dots: header.payload.signature. Each section is Base64url encoded so the token can be safely transmitted in URLs and HTTP headers.

Is it safe to use an online Base64 tool for sensitive data?

This tool processes everything entirely in your browser using JavaScript. No data is sent to any server. However, Base64 is not encryption, so the encoded output is just as sensitive as the original input. Do not paste passwords, private keys, or confidential data into any online tool including this one.

Related tools