Base64 Encoder and Decoder: Text and Files in Your Browser
Turn text or files into Base64, or decode Base64 back to readable text, as you type. UTF-8 safe, and nothing leaves your device.
Rate this toolBase64 Studio
Encode · decode · files to data URIs
Your input
Converts as you type. Files up to 5 MB become data URIs.
Base64 output
Type text or upload a file. The Base64 appears here.
UTF-8 safe: emoji and non-Latin text encode and decode losslessly. Base64 is an encoding, not encryption.
- Directions
- 2Directions
- Characters in the alphabet
- 64Characters in the alphabet
- Largest file
- 5 MBLargest file
- Files uploaded
- 0Files uploaded
Keep working with your data
Tools that pick up where this one leaves off.
Base64 in three steps
From text, a file or a pasted string to the other side, without installing anything or uploading a byte.
- STEP 01
Pick a direction
Encode turns text or a file into Base64. Decode turns Base64 back into text.
Switch any time - STEP 02
Type, paste or upload
The result updates as you type. Files up to 5 MB become a data: URI.
UTF-8 safe - STEP 03
Copy or download
Copy the result, download it as a .txt file, or swap it back into the input.
Swap to check a round trip
How to use this Base64 tool
Base64 turns any bytes into plain letters and digits, so binary data can travel through places that only accept text.
- 1
Encode text
Type or paste. Accents, emoji and non-Latin scripts are encoded as UTF-8 first, so they decode back exactly.
- 2
Encode a file
Upload an image or any file up to 5 MB. You get a data: URI ready to paste into HTML or CSS.
- 3
Decode a string
Paste Base64. URL-safe characters, missing = padding, line breaks and a data: prefix are all fixed for you.
- 4
Check the round trip
Tap Swap to send the output back as input in the other direction and confirm you get the original.
Using Base64 well
Four things to know before you rely on Base64 in a project.
It's not encryption
Anyone can decode Base64. It hides nothing, so never use it to protect passwords or keys.
- No key involved
- Decodes in one step
- Encrypt secrets instead
It's a third bigger
Every 3 bytes become 4 characters, so encoded data is about 33% larger than the original.
- 3 bytes = 4 chars
- Plus up to 2 = signs
- Bigger pages if inlined
Pick the right variant
Standard Base64 uses + and /. The URL-safe variant uses - and _ so it fits in URLs.
- Standard: + /
- URL-safe: - _
- JWTs use URL-safe
Mind the character set
Text must become bytes first. This tool uses UTF-8, the encoding the web uses by default.
- UTF-8 in, UTF-8 out
- Emoji safe
- Same on every device
How Base64 turns bytes into text
Three bytes in, four characters out, using an alphabet of 64 safe characters.
Group into 24 bits
Take the input three bytes (24 bits) at a time.
- 3 bytes per group
- 8 bits each
- 24 bits total
Split into 6-bit pieces
Cut the 24 bits into four 6-bit numbers, each between 0 and 63.
- 4 pieces
- 6 bits each
- Values 0 to 63
Look up the alphabet
Each number becomes one character: A-Z, a-z, 0-9, then + and /.
- 0 = A
- 26 = a
- 62 = +, 63 = /
Pad the end
If the last group has 1 or 2 bytes, = signs fill it to 4 characters.
- 1 byte left = ==
- 2 bytes left = =
- URL-safe often drops =
Where Base64 turns up
It's everywhere text has to carry binary data.
Web developers
Small images and fonts inlined into HTML or CSS as data: URIs save a request.
APIs and DevOps
HTTP Basic auth headers, Kubernetes secrets and many API payloads carry Base64 values.
Auth and tokens
Each part of a JWT is base64url without padding. Decoding one shows its JSON.
Attachments travel as Base64 inside the message, split into lines of up to 76 characters.
Three facts that explain most Base64 surprises
From RFC 4648, the standard that defines Base64.
Output size
Every 3 bytes become 4 characters, so the output is about a third bigger.
Two alphabets
The standard alphabet and the URL-safe one differ in just two characters.
- Standard: A-Z a-z 0-9 + /
- URL-safe: A-Z a-z 0-9 - _
- Padding with = in both
Common mistakes
These cause most “invalid Base64” errors and garbled text.
- Treating Base64 as encryption
- Decoding a cut-off string
- Decoding an image as text
- Inlining large images
Keeping Base64 data manageable
Encoded data is easy to make and easy to forget about.
- 1
Inline only small files
A data URI is a third bigger than the file and can't be cached on its own. Keep inlined images small.
- 2
Label what it is
Store the type with the data, like a data: URI's image/png, so the next person knows how to decode it.
- 3
Treat it as sensitive
Base64 secrets in config files are still secrets. Keep them out of public repos and logs.
- 4
Decode to check
Before you ship an encoded value, decode it once and confirm it's what you expect.
This tool vs the command line vs upload sites
All three give the same Base64. They differ in convenience and where your data goes.
| Feature | CleverTools Base64 | base64 or certutil in a terminal | Sites that upload your data |
|---|---|---|---|
| Data leaves your device | ✓ Never | ✓ Never | ✗ Yes |
| Converts as you type | ✓ Yes | ✗ No | Varies |
| URL-safe and padding fixes | ✓ Automatic | Flags or extra steps | Varies |
| Files to data URIs | ✓ Up to 5 MB | Build the prefix yourself | Varies |
| Very large files | ✗ 5 MB limit | ✓ Any size | ✗ Upload limits |
| Install needed | ✓ No | Terminal | ✓ No |
Got a JWT? The JWT Decoder splits it and decodes every part at once.
Pro tips for Base64
Shortcuts and checks that save time.
Length is a clue
Standard Base64 with padding is always a multiple of 4 characters long.
Spot URL-safe
A - or _ in the string means URL-safe Base64. This tool decodes both.
Images need a viewer
This decoder returns text, so an image won't decode here. Paste its data: URI into a browser tab instead.
Line breaks are fine
Email and PEM files wrap Base64 into lines. The decoder ignores the breaks.
Check before you run
Decoded text from an unknown source can be a script. Read it, don't run it.
Basic auth
An HTTP Basic header is Base64 of user:password. Anyone who sees it can read the password.
Use Swap
Swap sends the output back the other way. A clean round trip proves the conversion.
Download long output
Long Base64 is easier to move as a .txt file than through the clipboard.
A file upload gives you data:image/png;base64,…, not just the Base64. The part before the comma tells the browser what the data is. Keep it when you paste into an img src or a CSS url().
Encoding or encrypting? They are not the same
Base64 looks scrambled, which is why it's often mistaken for security.
Make data fit through text
Base64 changes how data is written so it can pass through text-only places. No key, no secrecy.
Best for data URIs, headers and payloads
Keep data private
Encryption makes data unreadable without the key. Use it for anything that must stay secret.
Best for passwords, keys and private files
Who uses this Base64 tool
Six everyday reasons to encode or decode.
Web developers
Inlining a small icon or font as a data URI in HTML or CSS.
DevOps engineers
Encoding values for Kubernetes secrets and decoding ones from configs.
API developers
Reading a Base64 field from an API response or building a Basic auth header.
Security analysts
Decoding suspicious strings from emails or logs without running them.
Email developers
Checking what an encoded email part really contains.
Students
Watching how padding and the 4-for-3 size rule work on real input.
Frequently asked questions
Quick answers about encoding, decoding, files and what Base64 can and can't do.
What is Base64 encoding?
Is the Base64 tool free?
Can I encode files?
Is my data safe?
Does it support Unicode text?
What people say
Reviews from people who used this tool.
Loading reviews…
Popular presets
Jump to a version of this tool already set up for a specific need.
- PresetBase64 Encoder OnlineBase64 encoder online: turn text into UTF-8 safe Base64 for Basic Auth headers, JSON payloads or data URIs, and decode it back.Open preset
- PresetImage to Base64 ConverterImage to Base64: turn a JPG, PNG, WebP, SVG or GIF up to 5 MB into a data URI with the right MIME prefix, ready for CSS, HTML or JSON.Open preset
- PresetFile to Base64 ConverterFile to Base64: drop a PDF, DOCX, ZIP, MP3 or any file and get its Base64 string with a data URI prefix.Open preset
More free developer tools
Free, with no sign-up, just like this one.
- Free toolJWT DecoderDecode and inspect JSON Web Tokens - view header, payload, expiry, and claims instantlyTry it now
- Free toolFavicon GeneratorTurn any image into the full favicon set - six standard sizes plus the HTML meta tags ready to paste, generated locally in your browser.Try it now
- Free toolHash GeneratorGenerate MD5, SHA-1, SHA-256, SHA-512 hashes from text or filesTry it now
- Free toolUnix Timestamp ConverterConvert Unix timestamps to human dates and vice versa with live clockTry it now
- Free toolRegex TesterTest regular expressions with live matching, highlighting, and group extractionTry it now
- Free toolCron Expression GeneratorBuild, preview, and copy cron expressions visually with presets and next run time previewTry it now