Skip to content
Researched developer tool comparisonsPrices dated · vendor sources linked · no star ratings
Search

Stage 01 · Write · Researched comparison

Best Go HTML Parsers in 2026

golang.org/x/net/html is the first pick for most teams. It is the standard tokenizer and tree parser that other Go HTML libraries build on, and it suits developers who want full control with no extra dependencies. Choose goquery if you want jQuery-style selection, and colly if you are building a scraper rather than just parsing a document. htmlquery is the better fit when you prefer XPath over CSS selectors.

By
Published 27 Nov 2026 · 6 tools compared

We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.

Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.

Key takeaways

  • golang.org/x/net/html, goquery, colly, htmlquery, cascadia and bluemonday are all free and open source.
  • x/net/html is the base parser; goquery, cascadia and htmlquery add selection layers on top of it.
  • colly wraps parsing in a full scraping framework with scheduling and request control.
  • bluemonday is a sanitizer, not a general parser, and is best paired with one of the others.

Who each pick is for

  • Developers who want a low-level, dependency-light HTML parsergolang.org/x/net/html
  • Developers who want jQuery-style CSS selection in Gogoquery
  • Developers building crawlers that parse HTML at scalecolly
  • Developers who prefer XPath over CSS selectorshtmlquery
  • Developers who want CSS selectors without the goquery wrappercascadia
  • Developers who need to sanitize untrusted HTML safelybluemonday

Comparison

The 6 tools at a glance
ToolBest forStandout featureListed starting priceFree plan or trial
1golang.org/x/net/htmlDevelopers who want a low-level, dependency-light HTML parserOfficial Go extended libraryFree (open source)Free plan
2goqueryDevelopers who want jQuery-style CSS selection in GoFamiliar jQuery-like APIFree (open source)Free plan
3collyDevelopers building crawlers that parse HTML at scaleBuilt-in request scheduling and rate limitsFree (open source)Free plan
4htmlqueryDevelopers who prefer XPath over CSS selectorsFull XPath 1.0 query supportFree (open source)Free plan
5cascadiaDevelopers who want CSS selectors without the goquery wrapperSmall, focused CSS selector libraryFree (open source)Free plan
6bluemondayDevelopers who need to sanitize untrusted HTML safelyPolicy-based allowlists for tags and attributesFree (open source)Free plan

How we picked

We compared these libraries on fit for HTML parsing in Go, platform and runtime support, licence and price, and the main limits of each. We also weighed how they handle malformed markup and whether they help with sanitizing untrusted input. Sources are vendor pages, official documentation and project repositories. Prices and licences can change, so confirm details on each project's site before you commit.

The tools, one by one

01

golang.org/x/net/html

Best for developers who want a low-level, dependency-light HTML parser

Visit pkg.go.dev
golang.org/x/net/html homepage
golang.org/x/net/html homepage, captured Nov 2026

What it is and where it fits

This package provides the tokenizer and tree parser that much of the Go ecosystem relies on. It handles malformed markup the way browsers do, producing a node tree you can traverse manually. Because it lives under golang.org/x/net, it is maintained alongside the Go project and follows the same compatibility promises.

It runs anywhere Go runs and has no third-party dependencies. The trade-off is verbosity: finding elements means writing your own traversal code or pairing it with a selector library. There is no query language, no CSS or XPath support, and no sanitization. Teams that need to extract many elements will usually add goquery or cascadia on top.

Skip it if you want ready-made selectors. Choose it if you need a stable, minimal foundation and are comfortable writing traversal logic.

Standout: Official Go extended library

Pricing pointer

Free (open source), as listed by the vendor (golang.org/x/net/html website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Official Go extended library
  • tokenizer and tree parser in one package

Drawbacks

  • No selector helpers
  • you walk the node tree yourself

Skip it if this limit matters to you: no selector helpers.

Verdict. A sensible pick for developers who want a low-level, dependency-light HTML parser.

Alternatives in this guide: goquery, colly, htmlquery

02

goquery

Best for developers who want jQuery-style CSS selection in Go

Visit github.com
goquery homepage
goquery homepage, captured Nov 2026

What it is and where it fits

goquery wraps golang.org/x/net/html and adds a chainable selection API modeled on jQuery. You load a document, run CSS selectors, and read text, attributes or HTML from matched nodes. It is the most common choice for developers porting scraping or extraction code from JavaScript or Python.

It is a library, not a framework, so it does not fetch pages for you. You bring your own HTTP client and pass the response body in. The package depends on cascadia for selector matching, which means CSS selector support follows that project. There is no XPath, and very large documents still cost memory because the whole tree is held.

Skip it if you need XPath or a full crawling framework. It suits one-off extraction, tests, and small to medium scraping jobs.

Standout: Familiar jQuery-like API

Pricing pointer

Free (open source), as listed by the vendor (goquery website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Familiar jQuery-like API
  • built on x/net/html

Drawbacks

  • CSS selectors only
  • no XPath support

Skip it if this limit matters to you: CSS selectors only.

Verdict. A sensible pick for developers who want jQuery-style CSS selection in Go.

Alternatives in this guide: golang.org/x/net/html, colly, htmlquery

03

colly

Best for developers building crawlers that parse HTML at scale

Visit github.com
colly homepage
colly homepage, captured Nov 2026

What it is and where it fits

colly is a scraping framework, not just a parser. It handles HTTP requests, concurrency, rate limiting, cookies and caching, and exposes parsed HTML through callbacks with CSS and XPath selectors. For teams that need to fetch and parse many pages, it removes a lot of glue code.

It runs anywhere Go runs and is distributed under an open-source license. Because it does more, it has more configuration to learn, and its abstractions can get in the way when you only need to parse a string you already have. Debugging concurrency issues in a crawler is also harder than debugging a single parse call.

Skip it if you already have HTML in memory and just need to extract nodes. Choose it when fetching, throttling and parsing are all part of the job.

Standout: Built-in request scheduling and rate limits

Pricing pointer

Free (open source), as listed by the vendor (colly website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Built-in request scheduling and rate limits
  • CSS and XPath selectors

Drawbacks

  • Larger surface area than a plain parser
  • overkill for single documents

Skip it if this limit matters to you: larger surface area than a plain parser.

Verdict. A sensible pick for developers building crawlers that parse HTML at scale.

Alternatives in this guide: golang.org/x/net/html, goquery, htmlquery

04

htmlquery

Best for developers who prefer XPath over CSS selectors

Visit github.com
htmlquery homepage
htmlquery homepage, captured Nov 2026

What it is and where it fits

htmlquery lets you query an HTML document with XPath expressions. It parses input through golang.org/x/net/html and returns matched nodes, so you can mix manual tree work with XPath queries. It is part of the antchfx family of query libraries, which also covers XML and JSON.

It is free and open source and runs wherever Go runs. XPath is powerful for positional and attribute-based selection, but it is less common in web-focused codebases than CSS selectors, so onboarding new contributors can take longer. Documentation is thinner than goquery's, and examples are fewer.

Skip it if your team thinks in CSS selectors. Choose it if you are porting XPath logic or need selection patterns CSS handles awkwardly.

Standout: Full XPath 1.0 query support

Pricing pointer

Free (open source), as listed by the vendor (htmlquery website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Full XPath 1.0 query support
  • works with x/net/html trees

Drawbacks

  • XPath is less familiar to many developers
  • smaller community than goquery

Skip it if this limit matters to you: XPath is less familiar to many developers.

Verdict. A sensible pick for developers who prefer XPath over CSS selectors.

Alternatives in this guide: golang.org/x/net/html, goquery, colly

05

cascadia

Best for developers who want CSS selectors without the goquery wrapper

Visit github.com
cascadia homepage
cascadia homepage, captured Nov 2026

What it is and where it fits

cascadia implements CSS selector parsing and matching against golang.org/x/net/html nodes. It is the selector engine behind goquery, exposed directly for developers who want CSS queries without the jQuery-style wrapper. You keep full control of traversal and only borrow the selector logic.

It is free, open source, and small enough to audit quickly. The catch is that it does very little on its own: you still parse with x/net/html and walk results yourself. If you want chained helpers like text extraction or attribute reads, you end up writing them or adding goquery anyway.

Skip it if you want a batteries-included API. Choose it if you already have traversal code and only need CSS matching.

Standout: Small, focused CSS selector library

Pricing pointer

Free (open source), as listed by the vendor (cascadia website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Small, focused CSS selector library
  • used by goquery

Drawbacks

  • Selector matching only
  • no document loading or traversal helpers

Skip it if this limit matters to you: selector matching only.

Verdict. A sensible pick for developers who want CSS selectors without the goquery wrapper.

Alternatives in this guide: golang.org/x/net/html, goquery, colly

06

bluemonday

Best for developers who need to sanitize untrusted HTML safely

Visit github.com
bluemonday homepage
bluemonday homepage, captured Nov 2026

What it is and where it fits

bluemonday is an HTML sanitizer. It parses input and strips anything not allowed by a policy you define, which makes it useful when rendering user-submitted HTML. It is commonly paired with a parser like goquery or x/net/html when a pipeline both extracts and cleans content.

It is free and open source and runs anywhere Go runs. It is not a scraping or extraction library, so it will not help you find nodes by selector. Policies need care: too permissive and you keep risky markup, too strict and you break legitimate content. Test policies against real samples before shipping.

Skip it if your HTML is trusted and already clean. Choose it whenever untrusted markup reaches a browser.

Standout: Policy-based allowlists for tags and attributes

Pricing pointer

Free (open source), as listed by the vendor (bluemonday website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Policy-based allowlists for tags and attributes
  • pairs with common parsers

Drawbacks

  • Not a general-purpose extraction tool
  • policy must be tuned per use case

Skip it if this limit matters to you: not a general-purpose extraction tool.

Verdict. A sensible pick for developers who need to sanitize untrusted HTML safely.

Alternatives in this guide: golang.org/x/net/html, goquery, colly

Who should use what

If you need a stable base parser with no extra dependencies, start with golang.org/x/net/html. If your team is comfortable with jQuery-style code, goquery will feel familiar and cut boilerplate. If the job is crawling many pages with throttling, colly covers fetching and parsing together. If you already think in XPath, htmlquery is the direct fit, and if you handle user-submitted markup, add bluemonday to sanitize output.

Questions to settle before you buy

What to check before you buy

  • Confirm the library handles malformed HTML the way your source pages actually break.
  • Check whether you need CSS selectors, XPath, or manual traversal, and pick accordingly.
  • Review the licence and confirm it fits your distribution model.
  • Test memory use on your largest real documents, since tree parsers hold the whole document.
  • If input is untrusted, plan a sanitization step with a policy you have tested.

FAQ

Is golang.org/x/net/html a full HTML5 parser?

It implements the HTML5 tokenizer and tree construction rules closely enough for browser-like parsing of malformed markup. It does not include selectors or sanitization. Most Go HTML libraries build on it, so learning its node model helps even when you use a wrapper.

Do I need goquery if I use x/net/html?

No. goquery is optional. It adds CSS selection and chained helpers on top of x/net/html. If you only parse a few elements, manual traversal may be simpler. If you extract many fields, goquery usually saves code.

Can I use CSS selectors and XPath together?

Yes, by combining libraries. cascadia or goquery covers CSS, and htmlquery covers XPath, both working over x/net/html trees. Mixing them adds dependencies, so pick one style per project unless you have a clear reason.

Is colly a parser or a scraper?

It is a scraping framework that includes parsing. It manages requests, concurrency and rate limits, then exposes parsed HTML through callbacks. If you already have HTML in memory, a plain parser is lighter.

Does bluemonday replace a parser?

No. bluemonday sanitizes HTML according to a policy. It does not help you find or extract nodes. Use it alongside a parser when untrusted markup will be rendered.

Sources we checked

Method: how we score · editorial policy.

  1. golang.org/x/net/html (official site)
  2. goquery (official site)
  3. colly (official site)
  4. htmlquery (official site)
  5. cascadia (official site)
  6. bluemonday (official site)

Change log. First published 27 Nov 2026.