What is Base64?
Base64 turns any sequence of bytes — text, an image, a PDF — into a string made of just 64 “safe” characters: A–Z, a–z, 0–9, + and /. Many systems were designed to carry plain text only: email bodies, JSON fields, HTML attributes, HTTP headers. Wrapping binary data in Base64 lets it pass through them without being corrupted. Every 3 bytes become 4 characters, so the encoded version is roughly a third larger than the original.
When is it useful?
- Embedding a small icon straight into HTML or CSS as a data URI, like
data:image/png;base64,… - Sending a file inside a JSON API request or storing it in a text column.
- Building or checking an HTTP Basic
Authorizationheader. - Reading the parts of a JWT, which use the URL-safe variant without padding.
- Looking inside an email attachment or a PEM certificate block.
Things to watch out for
- It is not encryption. Anyone can decode Base64 in a second. Never use it to “hide” a password or an API key.
- Text becomes bytes first. This tool uses UTF-8, so Bangla, emoji and every other script round-trip exactly. The browser’s built-in
btoa()only accepts Latin-1 and throws “InvalidCharacterError” on Bangla text — a very common bug. - Two alphabets. URL-safe Base64 (RFC 4648) swaps
+for-and/for_, and often leaves out the=padding. The decoder here accepts both alphabets, with or without padding, and ignores line breaks.
FAQ
Is my data uploaded anywhere?
No. Encoding and decoding run entirely in your browser, and files are read locally with the FileReader API. Nothing leaves your device.
Can I turn Base64 back into an image or file?
Yes. Switch to Decode and paste the Base64 or a full data URI. PNG, JPEG, GIF and WebP images get a preview, and Download saves the original file with a matching extension.
What does “invalid character at position …” mean?
The input contains something that is not part of either Base64 alphabet — often a stray quote, a % from URL encoding, or text copied along with the data. The position tells you exactly where to look.
Base64 কী?
Base64 যেকোনো বাইটের ধারাকে — হোক তা টেক্সট, ছবি বা PDF — মাত্র ৬৪টি “নিরাপদ” অক্ষরে লেখা একটি স্ট্রিংয়ে রূপান্তর করে: A–Z, a–z, 0–9, + আর /। ইমেইল, JSON ফিল্ড, HTML অ্যাট্রিবিউট বা HTTP হেডারের মতো অনেক ব্যবস্থা শুধু সাধারণ টেক্সট বহনের জন্য তৈরি। বাইনারি ডেটাকে Base64-এ মুড়ে দিলে সেটি এসবের মধ্য দিয়ে নষ্ট না হয়ে পৌঁছায়। প্রতি ৩ বাইট হয়ে যায় ৪টি অক্ষর, তাই এনকোড করা ডেটা মূলের চেয়ে প্রায় এক-তৃতীয়াংশ বড় হয়।
কখন কাজে লাগে?
- ছোট আইকন সরাসরি HTML বা CSS-এ data URI হিসেবে বসাতে, যেমন
data:image/png;base64,… - JSON API রিকোয়েস্টের ভেতরে ফাইল পাঠাতে বা টেক্সট কলামে সংরক্ষণ করতে।
- HTTP Basic
Authorizationহেডার তৈরি বা যাচাই করতে। - JWT-এর অংশগুলো পড়তে — এগুলো প্যাডিং ছাড়া URL-safe Base64 ব্যবহার করে।
- ইমেইলের অ্যাটাচমেন্ট বা PEM সার্টিফিকেটের ভেতরে কী আছে দেখতে।
যেসব বিষয়ে সতর্ক থাকবেন
- এটি এনক্রিপশন নয়। যে কেউ এক সেকেন্ডে Base64 ডিকোড করতে পারে। পাসওয়ার্ড বা API কী “লুকাতে” কখনো এটি ব্যবহার করবেন না।
- টেক্সট আগে বাইটে রূপান্তরিত হয়। এই টুল UTF-8 ব্যবহার করে, তাই বাংলা, ইমোজি বা যেকোনো ভাষার লেখা হুবহু ফিরে আসে। ব্রাউজারের নিজস্ব
btoa()শুধু Latin-1 গ্রহণ করে এবং বাংলা দিলে “InvalidCharacterError” দেয় — এটি খুব প্রচলিত একটি বাগ। - দুই ধরনের বর্ণমালা। URL-safe Base64 (RFC 4648)
+-এর বদলে-আর/-এর বদলে_ব্যবহার করে, এবং প্রায়ই শেষের=প্যাডিং বাদ দেয়। এখানকার ডিকোডার দুই বর্ণমালাই গ্রহণ করে, প্যাডিং থাকুক বা না থাকুক, আর লাইন ব্রেক উপেক্ষা করে।
প্রশ্নোত্তর
আমার ডেটা কি কোথাও আপলোড হয়?
না। এনকোড ও ডিকোড সম্পূর্ণ আপনার ব্রাউজারেই হয়, আর ফাইল পড়া হয় FileReader API দিয়ে আপনার ডিভাইসেই। কিছুই বাইরে যায় না।
Base64 থেকে কি ছবি বা ফাইল ফিরিয়ে আনা যায়?
হ্যাঁ। “ডিকোড” বেছে নিয়ে Base64 বা পুরো data URI পেস্ট করুন। PNG, JPEG, GIF ও WebP ছবির প্রিভিউ দেখাবে, আর “ডাউনলোড” চাপলে সঠিক এক্সটেনশনসহ মূল ফাইলটি সেভ হবে।
“… নম্বর অবস্থানে অবৈধ অক্ষর” মানে কী?
ইনপুটে এমন কিছু আছে যা কোনো Base64 বর্ণমালার অংশ নয় — প্রায়ই একটি বাড়তি কোট, URL এনকোডিংয়ের %, বা ডেটার সাথে কপি হয়ে আসা অন্য লেখা। অবস্থান নম্বর দেখে ঠিক কোথায় সমস্যা তা খুঁজে পাবেন।