تخطى إلى المحتوى الرئيسي

مشفر Base64

Base64 encoding converts binary data (images, files, arbitrary bytes) into ASCII text using 64 printable characters. It is essential for embedding binary data in text-based protocols: HTTP headers, email attachments (MIME), JSON payloads, and data URLs in HTML/CSS. Our tool handles text-to-Base64, file-to-Base64, URL-safe Base64, and data URL generation.

إدخال نص

المخرجات

What is Base64?

Base64 is a encoding scheme that converts binary data into ASCII text format. It uses 64 safe characters to represent data, making it ideal for transmitting data across text-only channels.

Common uses include:

  • ترميز الصور كـ data URIs في HTML/CSS
  • ترميز بيانات الاعتماد في HTTP Basic Auth
  • نقل البيانات الثنائية عبر البريد أو APIs
  • تضمين الملفات الثنائية في JSON أو XML
شارك هذه الأداة
Developer Tools

حول Base64 Encoder / Decoder

Base64 encoding converts binary data (images, files, arbitrary bytes) into ASCII text using 64 printable characters. It is essential for embedding binary data in text-based protocols: HTTP headers, email attachments (MIME), JSON payloads, and data URLs in HTML/CSS. Our tool handles text-to-Base64, file-to-Base64, URL-safe Base64, and data URL generation.

كيفية الاستخدام

  1. Enter text or paste binary data to encode to Base64.
  2. Paste a Base64 string to decode back to text or binary.
  3. Upload an image to generate a Base64 data URL (data:image/png;base64,...).
  4. Toggle between standard Base64 (uses + and /) and URL-safe Base64 (uses - and _).

الصيغة والمنهجية

Base64 encodes 3 bytes → 4 characters. Output size = ceil(input bytes / 3) × 4. Padding with = to make output length a multiple of 4. Character set: A–Z, a–z, 0–9, +, / (standard) or -, _ (URL-safe). Encoded size ≈ input size × 4/3 (+33%). btoa() and atob() in JavaScript; base64_encode() in PHP.

حالات الاستخدام الشائعة

  • Embedding images directly in HTML/CSS without separate HTTP requests
  • JWT tokens: header and payload are Base64url encoded
  • API authentication: Basic Auth sends "username:password" as Base64
  • Email: MIME encoding for attachments (multipart/mixed)
  • Environment variables: storing binary secrets as Base64 in .env files

الأسئلة الشائعة

Base64 represents every 3 bytes of binary data as 4 ASCII characters. 3 bytes × 8 bits = 24 bits; divided across 4 characters of 6 bits each = 24 bits. But each Base64 character is stored as 1 byte (8 bits), not 6. So 3 bytes become 4 bytes — a 33% increase. For this reason, inline Base64 images in CSS increase CSS file size by 33%, which can outweigh the benefit of saving an HTTP request.
Standard Base64 uses characters + and / which have special meaning in URLs (+ = space, / = path separator) — they must be percent-encoded in URLs. Base64url replaces + with - and / with _ and omits the = padding, making the output URL-safe without encoding. JWT tokens, OAuth codes, and web-safe file identifiers use Base64url. Always use Base64url when the encoded value will appear in a URL.

أدوات ذات صلة

كل الأدوات →

دمج هذه الأداة في موقعك

مجاني للاستخدام الشخصي والتجاري. فقط انسخ الكود أدناه.