Developer tool
Base64 Encode and Decode
Encode and decode Base64 text with correct UTF-8, URL-safe option and padding control. Convert files to Base64 or data URIs and turn Base64 back into files.
Free, no sign-up. Runs in your browser; nothing is uploaded.
Options
Text
Base64
How to use the base64 encode and decode
Encode or decode text
Pick Encode to turn text into Base64, or Decode to read Base64 back as text. The result updates as you type. Text is converted with UTF-8, so café becomes Y2Fmw6k= and emoji survive the trip in both directions. If the decoded bytes are not valid UTF-8 text, the tool says so and suggests File mode instead of showing garbled characters.
Standard or URL-safe
Standard Base64 uses + and /. The URL-safe form uses - and _ so the string can sit inside a URL, a filename or a JWT without escaping. You can also switch off the = padding, which many URL-safe formats omit. When decoding you do not need to choose: both alphabets and padded or unpadded input are accepted, and line breaks are ignored.
Files and data URIs
In File mode, choose any file to get its Base64, with a size comparison. Tick the data URI option to get a ready-to-paste value such as data:image/png;base64,..., which you can use in an img tag, a CSS url() or an email template. Keep standard Base64 for data URIs, because browsers expect it.
To go the other way, choose Base64 to file and paste Base64 or a data URI. The tool reads the first bytes to detect the real type (PNG, JPEG, GIF, WebP, PDF, ZIP, SVG, JSON or text), suggests a matching file name, previews images, and lets you download the result.
When to use Base64, and when not to
- Good for small icons, tokens, and attachments carried inside JSON or email.
- Poor for large images on web pages: inline data cannot be cached separately and makes the HTML heavier. Serve those as normal files.
- It is encoding, not security. Do not rely on it to protect data.
Troubleshooting
- Invalid character: the message points to the position. Spaces and line breaks are fine, other symbols are not.
- Wrong length: the string was probably cut off when copied.
- Unreadable text: the data is probably binary. Use Base64 to file.
Frequently asked questions
Why does my emoji or accented text decode wrongly elsewhere?
Base64 encodes bytes, not characters. This tool converts text to UTF-8 bytes first, so accents, emoji and non-Latin scripts round-trip correctly. Tools that use Latin-1 produce different output for the same text.
What is URL-safe Base64?
Base64url replaces + with - and / with _, and the = padding is often dropped. It is used in JWTs, URLs and filenames, where + and / would be misread. The decoder here accepts both forms automatically.
Is Base64 encryption?
No. Anyone can decode it, so never use it to hide passwords or secrets. It only makes binary data safe to carry in text formats such as JSON, email or HTML.
Why is the Base64 string about a third bigger than my file?
Every 3 bytes become 4 characters, so the output is roughly 33% larger. Very large files are slow to handle as text, so the tool warns above 10 MB.
What does the error "wrong padding" or "invalid length" mean?
Base64 text is built from groups of 4 characters. Extra or missing characters, a single leftover character, or misplaced = signs break that rule. Check that the string was copied completely and has no stray characters.