How to convert Markdown MD to HTML format in Node.JS

Cloudmersive
2 min readMar 21, 2020

--

Markdown can be a very useful tool, but oftentimes we end up with MD files in situations where they aren’t compatible. Manually converting them with the app itself is not very efficient, so we need an automated method to perform this from Node.JS. Here’s where our API comes in. With a simple function call, we can achieve this in no time. Let’s look at how to do it.

First, install the client with npm install.

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

Following that, call our conversion function.

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ConvertWebApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertWebMdToHtml(inputFile, callback);

OK, task complete. Our MD file has been converted by the API and sent back in HTML form. And now you never have to worry about MD file problems again! We have a range of other APIs, including more that convert between different commonly used document types.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet