> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# XmlEssentials: The XML API .NET developers begged for

> System.Text.Json-shaped, UTF-8 first, 3x faster, 85% less memory, source generated, Native AOT ready, with XML 1.0 and 1.1 support.

For the better part of a decade, .NET developers have asked for XML that works the way JSON does in System.Text.Json: one static call to serialize, a UTF-8 reader that doesn't allocate, a source generator, and Native AOT that works. **XmlEssentials is that library.** It's a complete XML stack written from scratch, with no dependency on `System.Xml`, and it's ready for production today.

### The System.Text.Json equivalent for XML that .NET developers have been begging for!

> [card] 3.0× faster on average
>
> Than `System.Xml`, across 67 comparisons. The range is 1.1× to 19×, with one exception.

> [card] 85% less memory
>
> On average. 32 of the 67 comparisons allocate 0 bytes.

> [card] 104 bytes
>
> To parse a document of any size into a DOM. `System.Xml` needs 127 KB to 709 KB for the same files.

```csharp theme={"dark"}
using CloudNimble.Text.Xml;

var person = new Person { Name = "Ada", Age = 36 };

string xml = XmlSerializer.Serialize(person);
Person? copy = XmlSerializer.Deserialize<Person>(xml);
```

```xml theme={"dark"}
<?xml version="1.0" encoding="utf-8"?><Person><Name>Ada</Name><Age>36</Age></Person>
```

> [card] [Get started in five minutes](https://easyaf.nimbleapps.cloud/xmlessentials/quickstart.md)
>
> Install the package and read, write, and serialize your first document.

> [card] [See the numbers](https://easyaf.nimbleapps.cloud/xmlessentials/benchmarks.md)
>
> 3.0× faster than `System.Xml` on average, with 85% less memory allocated.

## Everything System.Text.Json taught you, now for XML

If you know System.Text.Json, you already know XmlEssentials. The types, the method names, and the patterns carry straight over.

| System.Text.Json | XmlEssentials | What it does |
| - | - | - |
| `JsonSerializer` | [`XmlSerializer`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/serialize) | Turns objects into XML and back with one static call |
| `Utf8JsonReader` | [`Utf8XmlReader`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/use-utf8xmlreader) | Reads UTF-8 one token at a time, without allocating |
| `Utf8JsonWriter` | [`Utf8XmlWriter`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/use-utf8xmlwriter) | Writes UTF-8 straight into your buffer or stream |
| `JsonDocument` | [`XmlDocument`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/use-xmldocument) | A read-only, pooled document you can query |
| `JsonNode` | [`XmlNode`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/use-xmlnode) | A document you can build and change in memory |
| `JsonSerializerContext` | [`XmlSerializerContext`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/source-generation) | Source-generated serialization with no reflection |
| `JsonSerializerOptions` | [`XmlSerializerOptions`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/configure-options) | Naming policies, converters, and limits in one place |
| `JsonConverter<T>` | [`XmlConverter<T>`](https://easyaf.nimbleapps.cloud/xmlessentials/guides/custom-converters) | Your own reading and writing for any type |

Coming from JSON? [Start with what's different about XML](https://easyaf.nimbleapps.cloud/xmlessentials/guides/migrate/from-system-text-json.md).

## Next to the code you have today

Hover over or select what you use now to see the same task in XmlEssentials, side by side, and what changes when you move.

What you use today

lines

XmlEssentials
lines

What changes

Side-by-side comparisons and the full list of differences are in the migration guides:

* [Migrate from XmlSerializer](https://easyaf.nimbleapps.cloud/xmlessentials/guides/migrate/from-xmlserializer.md)
* [Migrate from XmlReader and XmlWriter](https://easyaf.nimbleapps.cloud/xmlessentials/guides/migrate/from-xmlreader-xmlwriter.md)
* [Migrate from XDocument and XmlDocument](https://easyaf.nimbleapps.cloud/xmlessentials/guides/migrate/from-xdocument.md)
* [Coming from System.Text.Json](https://easyaf.nimbleapps.cloud/xmlessentials/guides/migrate/from-system-text-json.md)

## Lightning fast, and light on memory

XmlEssentials reads and writes UTF-8 directly. There's no transcoding to UTF-16, no string for every name, and no object for every node. Across 67 like-for-like benchmarks against `System.Xml`, it's 3.0× faster on average and allocates 85% less memory.

> [card] [Up to 19× faster](https://easyaf.nimbleapps.cloud/xmlessentials/benchmarks.md)
>
> Reading a value takes 56 ns. `System.Xml` takes 1,068 ns.

> [card] [3.1× to 3.4× faster parsing](https://easyaf.nimbleapps.cloud/xmlessentials/benchmarks.md)
>
> Real documents into a DOM, in 104 bytes instead of hundreds of kilobytes.

> [card] [Zero-allocation writes](https://easyaf.nimbleapps.cloud/xmlessentials/benchmarks.md)
>
> Serialize into a buffer you own and the library allocates 0 bytes.

On lists and graphs of objects it runs level with System.Text.Json, which is remarkable for a format that demands much more of a parser. The [benchmarks page](https://easyaf.nimbleapps.cloud/xmlessentials/benchmarks.md) shows every row, including the ones where JSON still wins and the one where `System.Xml` does.

## Built for .NET in 2027 and beyond

XmlEssentials targets .NET 10 and .NET 11 and nothing older. There's no .NET Framework or .NET Standard build to hold it back, so the API uses the language and the runtime as they are today.

> [card] [Source generation](https://easyaf.nimbleapps.cloud/xmlessentials/guides/source-generation.md)
>
> List your types on a context and a Roslyn incremental generator writes their metadata at build time. The serializer uses no reflection and generates no code at run time.

> [card] [Native AOT and trimming](https://easyaf.nimbleapps.cloud/xmlessentials/guides/native-aot.md)
>
> Publish with `PublishAot` and it works. A test in the suite publishes a real app with Native AOT and runs it.

> [card] [Safe by default](https://easyaf.nimbleapps.cloud/xmlessentials/guides/security.md)
>
> No DTDs, no external entities, and limits on depth and size. Billion-laughs and XXE attacks have nothing to attack.

> [card] [Streaming and async](https://easyaf.nimbleapps.cloud/xmlessentials/guides/streaming.md)
>
> `Stream`, `PipeReader` and `PipeWriter`, and `IAsyncEnumerable<T>`, each with a `CancellationToken`, so you can read a huge feed one item at a time.

> [card] [Spans and buffers](https://easyaf.nimbleapps.cloud/xmlessentials/guides/use-utf8xmlreader.md)
>
> `ReadOnlySpan<byte>`, `ReadOnlySequence<byte>`, and `IBufferWriter<byte>` throughout. The reader is a `ref struct` that lives on the stack.

> [card] [Your types, as you write them](https://easyaf.nimbleapps.cloud/xmlessentials/guides/immutable-types.md)
>
> Positional records, constructors, `init` and `required` members, internal types, dictionaries, and polymorphism. No public parameterless constructor needed.

> [card] [XML 1.0 and XML 1.1](https://easyaf.nimbleapps.cloud/xmlessentials/guides/xml-conformance.md)
>
> Both versions of the specification, plus Namespaces in XML, verified against the W3C conformance suite. `System.Xml` never implemented XML 1.1.

> [card] [No System.Xml](https://easyaf.nimbleapps.cloud/xmlessentials/why-xmlessentials.md)
>
> One package with no dependency on the old XML stack, so nothing of it lands in your trimmed app.

> [card] [Generic attributes](https://easyaf.nimbleapps.cloud/xmlessentials/guides/source-generation.md)
>
> `[XmlSerializable<Person>]`, `[XmlDerivedType<Dog>]`, `[XmlConverter<MoneyConverter>]`. The compiler checks the type, and there's no `typeof` to get wrong.

> [card] [Closed types](https://easyaf.nimbleapps.cloud/xmlessentials/guides/polymorphism.md)
>
> On .NET 11, declare a hierarchy `closed` and the serializer takes its derived types from the compiler. You register nothing.

> [card] [Today's value types](https://easyaf.nimbleapps.cloud/xmlessentials/guides/supported-types.md)
>
> `DateOnly`, `TimeOnly`, `Int128`, `UInt128`, and `Half` work out of the box, next to the types you've always had.

> [card] [Classes from your schema (preview)](https://easyaf.nimbleapps.cloud/xmlessentials/guides/xsd-source-generation.md)
>
> Add an `.xsd` file to your project and get types and a serialization context generated for you. In preview.

The same goes for what you don't see. Generated contexts reach `init`, `required`, and non-public members through `[UnsafeAccessor]`, not reflection, and the reader and writer are built on `SearchValues<T>`, `IUtf8SpanFormattable`, and frozen collections. As .NET adds to the language and the runtime, XmlEssentials is free to follow.

## How it compares

| | System.Xml | System.Text.Json | XmlEssentials |
| - | - | - | - |
| Format | XML | JSON | XML |
| One-call static serializer | No | Yes | Yes |
| UTF-8 span reader and `IBufferWriter<byte>` writer | No | Yes | Yes |
| Read-only DOM in pooled memory | No | Yes | Yes |
| DOM you can edit | Yes | Yes | Yes |
| Roslyn source generator | No | Yes | Yes |
| Native AOT serialization | No | Yes | Yes |
| Positional records and constructor parameters | No | Yes | Yes |
| Non-public types | No | Yes | Yes |
| Dictionaries | No | Yes | Yes |
| `IAsyncEnumerable<T>` streaming | No | Yes | Yes |
| XML 1.1 | No | | Yes |
| DTD processing and XSLT | Yes | | No |

XmlEssentials is deliberately not a drop-in copy of `System.Xml`. It leaves out DTDs, XPath, XSLT, and encodings other than UTF-8. If you need those, keep `System.Xml` for that part of your app. See [XML conformance](https://easyaf.nimbleapps.cloud/xmlessentials/guides/xml-conformance.md) for the exact boundary.

## Tested like a platform library

* **100% line coverage and 100% branch coverage**, enforced on every build.
* **Thousands of tests**, run on both .NET 10 and .NET 11.
* **283 cases from the W3C XML Conformance Test Suite**, plus real documents from other parsers' test suites.
* **Documents are read split at every byte offset**, so XML that arrives in pieces reads the same as XML that arrives whole.
* **Every sample in these docs is compiled and tested.** If the docs show output, a test asserts it.

## Dive in

> [card] [Quickstart](https://easyaf.nimbleapps.cloud/xmlessentials/quickstart.md)
>
> Install and write your first XML.

> [card] [Why XmlEssentials?](https://easyaf.nimbleapps.cloud/xmlessentials/why-xmlessentials.md)
>
> The story behind the library.

> [card] [Migrate](https://easyaf.nimbleapps.cloud/xmlessentials/guides/migrate/from-xmlserializer.md)
>
> Move over from `System.Xml`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.