How to Convert Base64 Text Data to Binary Content using Node.js

Cloudmersive
1 min readOct 25, 2023

--

We can simplify the process of storing base64 text data in binary format by using a free API to make our conversion.

Using the below code, we can take advantage of a free API that quickly converts base64 text data into binary format. We just need to install the SDK using either the following command:

npm install cloudmersive-convert-api-client --save

Or the following snippet, which we can add to our package.json:

  "dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}

And then we can use the below function to call the service (we’ll need a free-tier API key to authorize this request, which we can get by registering a free account on the Cloudmersive website):

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveConvertApiClient.EditTextApi();

var request = new CloudmersiveConvertApiClient.Base64DecodeRequest(); // Base64DecodeRequest | Input request


var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.editTextBase64Decode(request, callback);

That’s all there is to it — no more code required!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet