NkkinParser 1.0.0
dotnet add package NkkinParser --version 1.0.0
NuGet\Install-Package NkkinParser -Version 1.0.0
<PackageReference Include="NkkinParser" Version="1.0.0" />
<PackageVersion Include="NkkinParser" Version="1.0.0" />
<PackageReference Include="NkkinParser" />
paket add NkkinParser --version 1.0.0
#r "nuget: NkkinParser, 1.0.0"
#:package NkkinParser@1.0.0
#addin nuget:?package=NkkinParser&version=1.0.0
#tool nuget:?package=NkkinParser&version=1.0.0
NkkinParser 🚀
The fastest, lowest-allocation HTML5 parser in .NET
Faster than AngleSharp on parsing and selection, dramatically faster than HtmlAgilityPack on selection • SIMD-accelerated • Full tolerant HTML5 parsing • CSS selector engine with selector lists, nth-child formulas, and more
NkkinParser is a high-performance HTML/CSS parser built for .NET 10 from the ground up, using:
ReadOnlySpan<char>+ unsafe code in hot paths- AVX2/AVX-512 SIMD for tag/text/attribute scanning
- Arena-backed allocation, with optional opt-in object pooling for repeated parse/dispose cycles
- Compiled, cached selectors with ID/class/tag indexing
- Streaming pull parser for large documents
HtmlLoader.LoadAsync(url)for parsing directly from a URL with auto-decompression
No external dependencies.
Performance Benchmarks
Measured with the benchmark suite in this repo (NkkinParser.Benchmarks/) — synthetic generated documents, not real-world pages. Run with dotnet run -c Release --project NkkinParser.Benchmarks/NkkinParser.Benchmarks.csproj -- * to reproduce on your own hardware; full methodology (equal work per competitor, parse cost excluded from selector timings for all libraries, etc.) is documented in the benchmark source files.
The numbers below are from a short, low-iteration run (--job short, N=3) on an Intel Core i3-8100 (4 cores), .NET 10.0.10 — good enough to sanity-check relative performance, not publication-grade statistics (see the wide error margins). Re-run with the default job for tighter confidence intervals.
Parsing (ParsingBenchmark, per-operation time to parse three documents of ~10KB/100KB/1MB combined):
| Method | Mean | Allocated |
|---|---|---|
| AngleSharp – parse only | 116.7 ms | 117.9 MB |
| NkkinParser – parse only | 52.5 ms | 70.5 MB |
| AngleSharp – parse + traverse | 123.4 ms | 43.4 MB |
| NkkinParser – parse + traverse | 64.2 ms | 70.5 MB |
| AngleSharp – parse + serialize | 236.1 ms | 61.4 MB |
| NkkinParser – parse + serialize | 85.7 ms | 76.2 MB |
CSS selector queries (SelectorBenchmark, "a[href], div, span.class-name, #search" against a pre-parsed 5000-element document; parse cost excluded from all three):
| Method | Mean | Allocated |
|---|---|---|
| AngleSharp | 1.31 ms | 257.8 KB |
| NkkinParser | 0.75 ms | 488.8 KB |
| HtmlAgilityPack (XPath) | 325.0 ms | 4977.5 KB |
Streaming vs. sync parse (StreamingBenchmark, 10,000-element document):
| Method | Mean | Allocated |
|---|---|---|
NkkinParser – sync Parse |
35.1 ms | 51.5 MB |
NkkinParser – async ParseAsync |
58.9 ms | 56.4 MB |
ParseAsync still parses the whole document up front and then walks it asynchronously (Task.Yield per node) — it trades throughput for interleaving/backpressure, it isn't a lower-latency or lower-allocation path.
Usage Examples
Full DOM Parsing
using NkkinParser;
var html = await File.ReadAllTextAsync("page.html");
using var parser = new HtmlParser(html);
var document = parser.Parse();
var images = document.QuerySelectorAll("img[src]");
foreach (var img in images)
{
var src = img.Attributes.Get("src");
Console.WriteLine(src);
}
Scoped queries on an element
var article = document.QuerySelector("article");
var links = article?.QuerySelectorAll("a[href]");
Supported CSS selectors
Type/universal/#id/.class selectors, attribute selectors ([attr], [attr=val], [attr=val i] case-insensitive), combinators ( , >, +, ~), selector lists (a, b), and pseudo-classes: :first-child, :last-child, :first-of-type, :last-of-type, :nth-child(an+b), :nth-last-child(an+b), :nth-of-type(an+b), :nth-last-of-type(an+b), :not(...).
Test suite
87 tests covering tokenization, tree construction (including the adoption agency algorithm for misnested tags), selector matching, encoding detection, and streaming. Run with dotnet test.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 205 | 8/3/2026 |