Delete an Object from an Online DocX Document in Node.JS

Have you ever edited a Word document online and realized you need to remove an object (paragraph, table, image, etc.)? If so, you know that it can be a tedious task to attempt manually. By using our Remove Object function, you’ll save significant time in your overall process. This function can be used after our Begin Editing function, which opens up the document for editing.

Start the Remove Object function by running this command to install the SDK:

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

Or, you can add this snippet to your package.json:

  "dependencies": {
"cloudmersive-convert-api-client": "^2.4.8"

Next, you can call the function — be sure to have the path of your target object ready for this step. If you don’t have the path, you can obtain it using our Get-Image, Get-Paragraph, Get-Body, etc. APIs.

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.EditDocumentApi();var reqConfig = new CloudmersiveConvertApiClient.DocxRemoveObjectRequest(); // DocxRemoveObjectRequest | Document input requestvar callback = function(error, data, response) {
if (error) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.editDocumentDocxRemoveObject(reqConfig, callback);

The returned result will show that the object has been successfully removed from your Word document. To download and save your updates, simply close out the operation with our Finish Editing function.

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