Base64 Encoder is an online tool to convert text or files to base64. It encodes binary data so that it can be stored and transferred safely. The encoded text does not contain non-printable characters. It only contains ASCII characters. So, you don't have to worry about control characters messing with the syntax of the text formats such as HTML. You can also use this tool to encode audio files.
All processing happens on the client-side, locally in your browser. No data is uploaded.
Decode text or data encoded using Base64 encoding & download the output, all on the client side
View ToolWe use Base64 encoding to represent binary data in ASCII characters. It consists of 64 characters, including letters, numbers, and two symbols plus (+) and slash (/). Additionally, the equals sign (=) is the pad character at the end. The typical usage is to embed image data within scripts such as CSS. The cool thing about Base64 is that most programming languages support it natively using built-in APIs. You can decode and encode binary data without importing any external libraries.
In C#, the ToBase64String
method of System.Convert
class does this. This method takes a byte array as input and returns the result in ASCII string format. Typically, this is some binary data that we cannot transfer over the wire without corruption. However, you can also convert text into byte[] and then encode it using base64. One must question why this is needed because it is not the intended use of the Base-64 encoding scheme. In this form, you are just wasting bytes to represent your text data. Use Base64 strings if you want to perform binary to text encoding and transmit your data safely.
Check out the Programming Languages section below for a list of APIs for other languages. Read more at Wikipedia.
Settings Explained
1. Output Format
The output format wraps the Base64 in HTML tags, attributes, JSON, and XML. It supports the following output formats.
Plain text
Plain text is the default format, and it only generates the base64 string. You have the additional option to wrap long lines by splitting them.
Data URI
Generates a Data URI, which also contains the mime type. This URI forms the basis of a lot of the following output formats.
HTML Audio
This audio to base64 output format generates an HTML audio tag.
HTML Embed
Embeds the output and mime type in an HTML EMBED tag
HTML HyperLink
Embeds the output in the HREF attribute of an HTML Anchor tag
HTML Iframe
Embeds the output in the SRC attribute of an HTML iframe tag
HTML Object
Embeds the output and mime type in an HTML object tag
HTML Source
Embeds the output in the SRC attribute an HTML source tag
JavaScript Audio
Outputs a JavaScript code that can play the audio when executed
JavaScript Popup
Generates a JavaScript code that opens the content as a popup in the browser on click
JSON
Generates a JSON text with the mime type and base 64 string as properties of an audio node
XML
Generates an XML markup with an audio element
2. Split Long Lines
Wraps the lines after 75 characters for better viewing when turned on. However, the Copy Output button still copies the text as a single line.
Split Long Lines On
TG9yZW0gSXBzdW0gaXMgc2ltcGx5IGR1bW15IHRleHQgb2YgdGhlIHByaW50aW5nIGFuZCB0eX Blc2V0dGluZyBpbmR1c3RyeS4gTG9yZW0gSXBzdW0gaGFzIGJlZW4gdGhlIGluZHVzdHJ5J3M=
Split Long Lines Off
TG9yZW0gSXBzdW0gaXMgc2ltcGx5IGR1bW15IHRleHQgb2YgdGhlIHByaW50aW5nIGFuZCB0eXBlc2V0dGluZyBpbmR1c3RyeS4gTG9yZW0gSXBzdW0gaGFzIGJlZW4gdGhlIGluZHVzdHJ5J3M=
Value | Char |
---|---|
0 | A |
1 | B |
2 | C |
3 | D |
4 | E |
5 | F |
6 | G |
7 | H |
8 | I |
9 | J |
10 | K |
11 | L |
12 | M |
13 | N |
14 | O |
15 | P |
Value | Char |
---|---|
16 | Q |
17 | R |
18 | S |
19 | T |
20 | U |
21 | V |
22 | W |
23 | X |
24 | Y |
25 | Z |
26 | a |
27 | b |
28 | c |
29 | d |
30 | e |
31 | f |
Value | Char |
---|---|
32 | g |
33 | h |
34 | i |
35 | j |
36 | k |
37 | l |
38 | m |
39 | n |
40 | o |
41 | p |
42 | q |
43 | r |
44 | s |
45 | t |
46 | u |
47 | v |
Value | Char |
---|---|
48 | w |
49 | x |
50 | y |
51 | z |
52 | 0 |
53 | 1 |
54 | 2 |
55 | 3 |
56 | 4 |
57 | 5 |
58 | 6 |
59 | 7 |
60 | 8 |
61 | 9 |
62 | + |
63 | / |
How to do Base64 encoding and decoding in various programming languages
- Language: C#
- Encode:
System.Convert.ToBase64String()
- Decode:
System.Convert.FromBase64String()
- Example: Example
- Documentation: Documentation
- Language: VB .NET
- Encode:
System.Convert.ToBase64String()
- Decode:
System.Convert.FromBase64String()
- Example: Example
- Documentation: Documentation
- Language: Java 8+
- Encode:
java.util.Base64.getEncoder().encode()
- Decode:
java.util.Base64.getDecoder().decode()
- Example: Example
- Documentation: Documentation
- Language: Java 7 or less
- Encode:
org.apache.commons.codec.binary.Base64.encodeBase64()
- Decode:
org.apache.commons.codec.binary.Base64.decodeBase64()
- Example: Example
- Documentation: Documentation
- Language: JavaScript
- Encode:
btoa()
- Decode:
atob()
- Example: btoa() atob()
- Documentation: Documentation
- Language: Python
- Encode:
base64.b64encode()
- Decode:
base64.b64decode()
- Example: Example
- Documentation: Documentation
- Language: Ruby
- Encode:
Base64.encode64()
- Decode:
Base64.decode64()
- Example: Example
- Documentation: Documentation
Use Cases
Convert MP3 to Base64
Using this tool, you can convert MP3 files to Base64 and transmit the binary data over a text format such as HTML.
- Click the Browse File button
- Click the output format
- Click the Encode button
- The base64 encoded MP3 file will be in the output
History
- Oct 11, 2021
- Support for multiple output formats
- Oct 27, 2017
- Support for uploading & encoding binary files
- Apr 1, 2018
- Improved handling of binary files
- Aug 20, 2017
- Tool Launched
Comments 0