leftarrow
Encoder Icon

Base64 Encoding and Decoding

Convert Base64 to Text or Image. Convert Plain Text or Image to Base64 format

Home

Developer Tools

Base64 Encoder


      
your image

Drag and drop an image

or Browse to choose a file

Copyicondownloadicon

What is Base64 Encoding and Decoding?

Base64 icon
  • Encoding is converting plain text input to a different format where each char is replaced by another value.
  • Base64 or B64 is an encoding system that represents every text char with 6 binary digits. (Readable Text => binary => Base64 encoded text)
  • It uses 3 bytes for 4 chars.
    Example of Base64 Encoded Output:
    VGhpcyBpcyBhIHBsYWluIHRleHQgaW5wdXQ=
    Input: This is a plain text input

  • Decoding is converting back the encoded text to plain text using the same encoder/decoder scheme. (Base64 encoded text => binary => readable text)
  • Base64 uses 65 from the ascii charset (64 + 1).
    The 65th one is = and is used for padding.
    64 are used for the actual encoding.
  • It is termed as base 64 because 64 is the base or radix. It is also called as Decode64 or Encode64 depending on whether it is decoding or encoding.
    Note: The radix for a decimal system is 10, the radix for a hexadecimal system is 16.

Steps to Convert Text to Base 64 using tool

Base64 icon
  • Select the option ' Text Encoder / Decoder'
  • Text to Base 64 is Encoding process. So, select the option 'Encode' to convert text to base 64.
  • Enter text in the input box or browse file to select a text file
  • The base 64 output appears automatically in the output. You can copy or download the output

Steps to Convert Base 64 to Text using tool

  • Select the option ' Text Encoder / Decoder'
  • Select the option 'Decode' to convert base 64 back to original text.
  • Enter base 64 data in the input field or browse and select file containing base64 data
  • If it's valid input, the plain text is automatically displayed in the output.

Steps to Convert Image to Base64 using tool

Base64 icon

  • Select option Image Encoder / Decoder
  • Click Browse and select an image or Drag n Drop an image to the input box
  • The base 64 image data is automatically displayed in the output box. You can copy or download the data to a file

Steps to Convert Base 64 to Image using Tool

  • With simple steps, you can convert your base 64 data to image.
  • Make sure the option selected is 'Image Encoder / Decoder'
  • Copy the image data in b64 format in the output box
  • This is a sample of initial part of image snippet in base 64 :
    9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBg
  • This part should be excluded while converting data:image/png;base64,
  • The preview section will automatically show you the corresponding image if it's valid.
  • You can right click and save or download the image file.
  • You can also copy or save the html and css snippet which can you copy directly into your html
The html snippet will appear like this
                                <img src="data:image/png;base64,iVBORw0KGgoAAAANS ...">
                                
                            

CSS:

                                background-image: url("data:image/png;base64,iVBORw .... )
    
                            

Base 64 to Ascii Table

Base64 Table icon
IndexCharacter6 digit binaryDecimal
0 A000000 65
1 B000001 66
2 C000010 67
3 D000011 68
4 E000100 69
5 F000101 70
6 G000110 71
7 H000111 72
8 I001000 73
9 J001001 74
10 K001010 75
11 L001011 76
12 M001100 77
13 N001101 78
14 O001110 79
15 P001111 80
16 Q010000 81
17 R010001 82
18 S010010 83
19 T010011 84
20 U010100 85
21 V010101 86
22 W010110 87
23 X010111 88
24 Y011000 89
25 Z011001 90
26 a011010 97
27 b011011 98
28 c011100 99
29 d011101 100
30 e011110 101
31 f011111 102
32 g100000 103
33 h100001 104
34 i100010 105
35 j100011 106
36 k100100 107
37 l100101 108
38 m100110 109
39 n100111 110
40 o101000 111
41 p101001 112
42 q101010 113
43 r101011 114
44 s101100 115
45 t101101 116
46 u101110 117
47 v101111 118
48 w110000 119
49 x110001 120
50 y110010 121
51 z110011 122
52 0110100 48
53 1110101 49
54 2110110 50
55 3110111 51
56 4111000 52
57 5111001 53
58 6111010 54
59 7111011 55
60 8111100 56
61 9111101 57
62 +111110 43
63 /111111 47
64 = (Padding character) 61

How to Convert Ascii Text to Base64 Manually

Base64 icon

These are steps to be followed for manual conversion

  • Find the Decimal Equivalent of each character. For eg if the word is ABC, then the decimal values are 65,66 and 67 respectively

  • For each of the decimal value of the character, convert to 8 bit binary equivalent 65 - 01000001
    66 - 01000010
    67 - 01000011
    Concatenate without spaces - 010000010100001001000011

  • Divide it into groups of 6 bit - 010000 010100 001001 000011

  • Find the base64 for each of the 6 bits as per the table 010000 is Q 010100 is U 001001 is J 000011 is D Base 64 encoded value for ABC is QUJD

  • Pad it up with = to make up upto 4 characters Like base 64 encoded value for Hello is SGVsbG8=
    Base 64 for A is QQ==

How to convert Base64 to Ascii Text Manually

These are steps to be followed for manual conversion

  • Find the Binary equivalent of the base 64 encoded data. let's take base64 encoded data as QQ==

  • The binary value for Q is 010000 QQ becomes 010000010000 and padded up with == which is empty and can be ignored

  • Extract the 8 bits ignoring the trailing zeros to get 01000001
    Convert to decimal value 0100001 is 65 and represents the character 'A'

ASCII icon

Frequently Asked Questions on Base64 Encoder and Decoder

FAQ icon

  • Base64 encoding or b64 encode is converting binary-text (readable text => binary => Base64 encoded text)
    Base64 encoding takes 6 bits of a 8 bit char value and converts it to Base64 equivalent of it (see table for the representation in Base64 of the ascii charset).
    So 2 chars needs 12 bits (1 byte + 4 bits) to encode to 1 symbol in base64
    3 chars of text input needs 18 bits (2 bytes + 2 bits)
    4 chars of text input needs 24 bits (3 bytes)

  • Base64 decoding or b64 decode means converting Base64 encoded data back to binary from which we get back the readable text .
    ( Base64 encoded text => binary => readable text)

  • Base64 scheme is used in URL encoding to escape special reserved characters for transmission over internet.
    It is also useful for image, audio/video, document encoding and transmission over the network
    It is more compact and a more human readable and understandable format than the binary system of 1's and 0's.
    Compared to hexadecimal encoding, it encodes more chars with less bytes.
    Therefore, it is considered more efficient than hexadecimal (Hexadecimal uses 8 bytes for 4 chars, Base64 uses 3 bytes for 4 chars)

  • Padding is done to indicate to the decoder that it is end of the stream and no additional bits for decoding.
    The padding character used in Base64 is = .
    The padding char is ignored and used only as an indicator
    This is most useful when multiple base64 encoding content is sent
    The base64 encoding takes groups of four 6 bit input (24 bits) to encode 4 chars.
    When there are less than 24 bits then it uses padding char one or more of padding (=) to fill up the remaining bits to make up the 24 bit.

  • it contains the ascii range of characters with a-z , A-Z and 1-9 and + / and one or two = for padding.

  • 3 bytes which represent 4 chars

  • 6 bits

  • UTF-8 is the standard encoding used for encoding text. Every character in Unicode has a unique code point.
    UTF-8 is a variable width encoding format.
    It uses 1 byte (8 bits) to represent ascii range characters and extends to 2, 3 or 4 bytes to cover full range of charset.
    UTF-8 is apt for text encoding, Base64 encoding is more suitable for binary form of data.
    It is fixed length of 6 bits for a char.
    It does not cover all character set like UTF-8. It's purpose is limited to data transmission without misinterpretation.

  • Hex is base 16 and uses range from 0-9 and A-F.
    Every char is represented by 2 hexadecimal (8 bits, 2bytes).
    Base64 uses base as 64 and range from 0-63.
    It uses 6 bits per char instead of 8 bits and so uses 33% less size.
    Hex encoding is more compact and simpler readable format.
    Base64 appears more complex with its larger range and with padding chars.

  • Basic authentication is one of the http authentication scheme
    Base64 is used to encode the user name and password while sending from client to server.
    The format uses the keyword Authorization: and then followed by the word Basic and the Base64 data.
    Authorization: Basic dXNlcm5hbWUvcGFzc3dvcmQ=
    Base64 encoded text can be decoded and it's not secure way of transmission.

  • This is pertaining to email message data transmission especially attachments like images, audio, video , docs etc.
    The binary form of email message / data is encoded into the plain text format using Base64 or any of other encoding algorithms and shared across email network.