---
title: "DOCX in C#: Read, create, and edit"
url: https://recursiveai.org/onedocument/articles/csharp-docx-library/
description: "Use OneDocument to read, create, and edit DOCX in C# without Word."
date: 2026-12-01
author: OneDocument team
---

# DOCX in C#: Read, create, and edit

Use OneDocument to read, create, and edit DOCX in C# without Word.

December 1, 2026 · OneDocument team

[OneDocument](https://recursiveai.org/onedocument/) is a free, open-source C# document library from Recursive AI, licensed under [MIT or Apache-2.0](https://licenses.nuget.org/MIT%20OR%20Apache-2.0). [NuGet](https://www.nuget.org/packages/RecursiveAI.OneDocument.Documents/1.0.0) · [GitHub](https://github.com/recursive-ai-oss/onedocument-csharp)

*Install · .NET 10*

```
dotnet new console
dotnet add package RecursiveAI.OneDocument.Documents --version 1.0.0
```

OneDocument.Documents 1.0.0 targets .NET 10 (`net10.0`) only.

*Program.cs · .NET 10*

```
using RecursiveAI.OneDocument;
using RecursiveAI.OneDocument.Documents;
 
using (var draft = Document.Create())
{
    draft.Body.AddParagraph("Gate inspection: pending");
    draft.SaveAs("draft.docx");
}
using (var doc = Document.Open("draft.docx"))
{
    doc.Replace("pending", "complete");
    doc.SaveAs("updated.docx");
}
Console.WriteLine(Office.ExtractText("draft.docx").Trim());
Console.WriteLine(Office.ExtractText("updated.docx").Trim());
```

*Output from dotnet run*

```
Gate inspection: pending
Gate inspection: complete
```

The program creates a draft, edits a copy, and reads both saved files back as text. It does not start Word or use the rendering package.

## Which OneDocument package handles DOCX?

| Package | Choose it when |
|---|---|
| [Documents](https://www.nuget.org/packages/RecursiveAI.OneDocument.Documents/1.0.0) | You want to read, create, or edit a DOCX through paragraphs and styles. Start here for the example above. |
| [Core](https://www.nuget.org/packages/RecursiveAI.OneDocument/1.0.0) | You need shared APIs or direct access to file containers and XML. `Documents` already brings in Core. |
| [Schema](https://www.nuget.org/packages/RecursiveAI.OneDocument.Schema/1.0.0) | You want typed views of XML elements such as WordprocessingML, rather than the high-level document model. `Documents` already brings in Schema. |
| [Rendering](https://www.nuget.org/packages/RecursiveAI.OneDocument.Rendering/1.0.0) | You need to lay out pages or export a [PDF](https://recursiveai.org/onedocument/cookbook/convert-docx-to-pdf/) or page image. |

DOCX stores document parts such as the main text and styles in a ZIP container. Opening or editing those parts isn’t the same as laying out pages. If you only need the words or want to change a heading and save another DOCX, you don’t need a renderer. See the [package list at 1.0.0](https://recursiveai.org/onedocument/docs/overview/#packages) for the full split.

## Pick the API by what you need back

- **Text or structure from an existing file:** `Office.ExtractText` gives you text for an index or preview. `Document.Open` gives you structure, so you can distinguish a heading by its style instead of guessing from its text. See [read a Word document](https://recursiveai.org/onedocument/cookbook/read-word-document/).
- **A new Word file:** start with `Document.Create` for content you generate in code. Start with [an existing template](https://recursiveai.org/onedocument/cookbook/fill-word-template/) when the document already has the styles and structure you want. See [create a Word document](https://recursiveai.org/onedocument/cookbook/create-word-document/) for the blank-file path.
- **An edited Word file:** use `Document.Open` and `SaveAs` to write a separate copy while you check the result. Use the [find and replace recipe](https://recursiveai.org/onedocument/cookbook/find-and-replace-in-word/) to handle phrases split across differently formatted runs and inspect any matches left unchanged.
