Công Cụ Nhanh

Base64 encode and decode online

Direction

 

 

Processed in your browser. Your files and data are never uploaded to a server.

Quick answer

Base64 represents any data with 64 safe characters (A–Z, a–z, 0–9, + and /), turning every 3 bytes into 4 characters, so output is about 33% larger. “Hello, World!” (13 bytes) encodes to SGVsbG8sIFdvcmxkIQ==.

What is Base64?

This tool encodes and decodes Base64 for UTF-8 text and for any file up to 10 MB. It supports standard Base64, Base64URL as used in JWTs, 76-character MIME line wrapping and data URIs; when decoding back to a file, the file type is detected from its content. Everything runs in your browser.

Illustration of a document turning into a ribbon of small tiles and back into the document

How to encode and decode Base64

  1. 1

    “Text” tab: choose “Encode → Base64” or “Decode Base64 →”, then type or paste; the result appears alongside.

  2. 2

    Turn on “Base64URL” for URLs, file names or JWTs, and line wrapping for email. Click “Swap” to decode the result back.

  3. 3

    “File” tab → “File → Base64”: click “Choose a file to encode”, optionally output a data URI, then copy or “Download .txt”.

  4. 4

    “File” tab → “Base64 → File”: paste Base64 or a data URI, check the detected type, preview images and download the file.

Base64 variants

VariantCharactersTrailing =Used for
Standard Base64 (RFC 4648)A–Z a–z 0–9 + /YesData in JSON, XML, configs
Base64URL (RFC 4648 §5)A–Z a–z 0–9 - _Usually dropped (this tool drops it)URLs, file names, JWTs
MIME (email)Same as standardYesEmail attachments, lines wrapped every 76 characters
Data URIStandard, with a data:…;base64, prefixYesEmbedding small images or fonts in HTML / CSS

Swipe sideways to see the whole table →

Size after encoding

Every 3 bytes become 4 Base64 characters (rounded up), so the output is about 4/3 of the original.

OriginalBase64Notes
1 byte4 characters (two =)Padding fills the group of four
13 bytes (“Hello, World!”)20 charactersAccented letters take 2–3 bytes in UTF-8
300 KBAbout 400 KBImages embedded as data URIs make HTML heavier
3 MB4 MBWrapping every 76 characters adds about 1.3% in line breaks

Real-world examples

Reading a JWT payload

A JWT has three dot-separated parts. Paste the middle one in decode mode: Base64URL is detected and the JSON payload (user, expiry…) is shown. The signature is not verified.

Inlining a small icon in CSS

Pick a small SVG or PNG on the File tab, enable data URI and paste it into background-image: url(…). Only worth it for tiny files, since size grows by about a third.

Recovering an image from an API

An API returns an image as a Base64 string? Paste it into “Base64 → File”: PNG or JPEG is detected from the content, previewed and downloaded with the right extension.

Encoding accented text

“Xin chào Việt Nam” becomes WGluIGNow6BvIFZp4buHdCBOYW0= and decodes back exactly, because UTF-8 is used in both directions.

Common mistakes

Decoding gives garbage or “not UTF-8 text”.
The original data is a binary file (image, PDF, zip…). Use the “File” tab → “Base64 → File” to restore the file instead of reading it as text.
Invalid length error.
Characters are missing, usually from an incomplete copy. Spaces and line breaks are fine; they are ignored.
Character not in the Base64 alphabet.
Stray spaces, brackets or surrounding text crept in. The message gives the exact position to delete.
“=” in the wrong place.
At most two = are allowed, at the very end. You may have joined two Base64 strings; decode each separately.
Files over 10 MB cannot be chosen.
The 10 MB cap keeps the browser responsive. For bigger files, send the original file rather than Base64.
Treating Base64 as security.
Base64 just rewrites data and anyone can decode it. Never use it to hide passwords or sensitive data.

Glossary

Base64 encoding
Turning bytes into a string of 64 safe characters so data can travel through text-only systems.
Padding (=)
One or two = at the end that complete the last group of four when data is not a multiple of 3 bytes.
Base64URL
A variant replacing + / with - _ so strings are safe in URLs and file names.
Data URI
A string like data:<type>;base64,<data> that embeds a file directly in HTML or CSS.
UTF-8
How text becomes bytes; accented letters take 2–3 bytes, which is why UTF-8 is needed to decode them correctly.
Magic bytes
The first few bytes that identify a file type (PNG, JPEG, PDF…), used to detect a decoded file.

Frequently asked questions

Is Base64 encryption?

No. Base64 only changes how data is written; there is no secret key and anyone can decode it. Use real encryption such as AES for secrecy.

Is Base64URL detected automatically when decoding?

Yes. Strings with - or _ or without trailing = decode fine, and the tool reports that Base64URL was detected.

Can I paste a data URI?

Yes. The “data:…;base64,” prefix is removed automatically; a data URI without “;base64” is reported clearly.

Which file types are detected?

More than 25 common ones such as PNG, JPEG, GIF, WebP, PDF, ZIP, SVG, MP3 and MP4, based on the first bytes. Unknown data still downloads with a .bin extension.

Will very long Base64 strings slow the page down?

Long results only show their beginning and large pasted input is collapsed; copying and downloading always use the full data.

Is my data uploaded?

No. Text and files are processed in your browser, including when you download the result.

Ratings and comments

Loading…