How to Remove Text from DOCX

Removing text and content from Word documents is essential for document cleanup, redaction, and content management tasks. Flexible methods help delete paragraphs, text runs, and other elements from DOCX files while maintaining document structure and integrity.

In this how-to, different ways of removing text using IronWord will be demonstrated.

Get started with IronWord

Start using IronWord in your project today with a free trial.

First Step:
green arrow pointer


Remove Text Example

To remove a paragraph from a Word document, access it through the Paragraphs collection using its index position. In this example, we remove the paragraph at index 1, which deletes all its content and formatting. The document structure automatically adjusts after removal.

:path=/static-assets/word/content-code-examples/how-to/remove-text-simple.cs
using IronWord;

// Load a DOCX document
WordDocument doc = new WordDocument("text_document.docx");

// Remove the second paragraph
doc.Paragraphs[1].Remove();

// Export the file
doc.SaveAs("text_document_modified.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Before Removal

Document before paragraph removal

After Removal

Document after paragraph removal

Removing Specific Text Run

A paragraph can contain multiple text runs, where each run represents text with consistent formatting properties like bold, italic, or color. To remove specific formatted content within a paragraph, access the Texts collection and target the desired text run by index. This example removes the third text run (index 2) from the first paragraph, leaving other content intact.

:path=/static-assets/word/content-code-examples/how-to/remove-text-text-run.cs
using IronWord;

// Load a DOCX document
WordDocument doc = new WordDocument("sample.docx");

// Remove the first paragraph's third textrun
doc.Paragraphs[0].Texts[2].Remove();

// Export the file
doc.SaveAs("sample_after_textrun_removal.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Before Text Run Removal

Document before text run removal

After Text Run Removal

Document after text run removal

Find and Remove Example

The FindText method locates and removes content dynamically based on text matching rather than position. This is useful for removing invalid text, placeholders, or specific content anywhere in the document. The method returns the matching text element or null if not found, allowing safe removal with a null check before calling Remove.

:path=/static-assets/word/content-code-examples/how-to/remove-text-find.cs
using IronWord;

// Load the document
WordDocument doc = new WordDocument("sample.docx");

// Find and remove erroneous text
var textToRemove = doc.FindText("ERRONEOUS TEXT IS HERE.");
textToRemove?.Remove();

// Save the cleaned document
doc.SaveAs("sample_cleaned.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Before Find and Remove

Document before finding and removing text

After Find and Remove

Document after finding and removing text

Frequently Asked Questions

What is the main purpose of removing text from DOCX files?

Removing text from DOCX files is essential for document cleanup, redaction, and content management tasks, ensuring the document maintains its structure and integrity.

How can I start using IronWord to remove text from Word documents?

To get started with IronWord, download the C# library, load the existing Word document, identify the text content to remove, use the Remove method, and save the updated document.

Can IronWord remove entire paragraphs from a DOCX document?

Yes, IronWord allows you to remove entire paragraphs by accessing them through the Paragraphs collection and deleting the desired paragraph at its index position.

Is it possible to remove specific text runs within a paragraph using IronWord?

Yes, you can remove specific text runs within a paragraph by accessing the Texts collection and targeting the text run by its index, allowing you to delete formatted content without affecting the rest of the paragraph.

How does the FindText method work for removing text in IronWord?

The FindText method dynamically locates and removes content based on text matching, which is useful for deleting invalid text, placeholders, or specific content throughout the document.

What happens to the document structure after text removal with IronWord?

After removing text with IronWord, the document structure adjusts automatically, ensuring that the overall format and integrity of the document are maintained.

Can IronWord handle removal of text with specific formatting like bold or italic?

Yes, IronWord can remove text with specific formatting such as bold or italic by targeting the specific text run within a paragraph that has the desired formatting properties.

What should be considered before using the Remove method in IronWord?

Before using the Remove method, ensure that the text element is not null to avoid errors, as the FindText method returns null if no matching content is found.

Does IronWord support removal of placeholders in Word documents?

Yes, IronWord supports the removal of placeholders by using the FindText method to locate and remove placeholder content from the document.

Ahmad Sohail
Full Stack Developer

Ahmad is a full-stack developer with a strong foundation in C#, Python, and web technologies. He has a deep interest in building scalable software solutions and enjoys exploring how design and functionality meet in real-world applications.

Before joining the Iron Software team, Ahmad worked on automation projects ...

Read More
Ready to Get Started?
Nuget Downloads 25,693 | Version: 2025.11 just released