Languages
[Edit]
EN

JavaScript - convert Blob to base64

7 points
Created by:
Giles-Whittaker
739

In this article, we would like to show how using JavaScriptconvert blob or file objects to Base64.

In the article, we present two solutions.

1. Data URL with Base64 example

Edit

In this section, the presented solution returns base64 data for an indicated blob or file object.

In JavaScript, it is possible to convert objects to Data URLs with different encodings. Using base64 encoding we are able to extract data easily.

Data URL concept:

Where ... used to shortcut long values I the presented example.

 

Data URLs were created to store data in URL. The above dataUrl can be used to display images, e.g.:

Note: read this article to see practical online runnable example.

 

Practical example:

Example output (dataUrl value):

 

2. Only Base64 data example

Edit

In this section, the presented solution returns only base64 data from indicated blob or file objects.

Practical example:

Example output:

 

Alternative titles

  1. JavaScript - convert File to base64
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join