A fork of https://github.com/k3a/html2text I'm using as a starting point for the apres web parser.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Jason J. Gullickson 6b067f354d
2 weeks ago
.github/workflows Add CI for tests 3 months ago
.travis.yml master go ver 4 years ago
LICENSE readme and lic, more tests 6 years ago
README.md update README 1 year ago
entity.go Add support for more named character references 4 years ago
go.mod Revert module path. 2 weeks ago
go.sum support hexadecimal numeric html entities, fixes #13 2 years ago
html2text.go WIP. 2 weeks ago
html2text_test.go WIP. 2 weeks ago


GoDoc Build Status Coverage Status Report Card


A simple Golang package to convert HTML to plain text (without non-standard dependencies).

It converts HTML tags to text and also parses HTML entities into characters they represent. A <head> section of the HTML document, as well as most other tags are stripped out but links are properly converted into their href attribute.

It can be used for converting HTML emails into text.

Some tests are installed as well. Uses semantic versioning and no breaking changes are planned.

Fell free to publish a pull request if you have suggestions for improvement but please note that the library can now be considered feature-complete and API stable. If you need more than this basic conversion, please use an alternative mentioned at the bottom.


go get github.com/k3a/html2text


package main

import (

func main() {
	html := `<html><head><title>Good</title></head><body><strong>clean</strong> text</body>`
	plain := html2text.HTML2Text(html)

/*	Outputs:

	clean text

To see all features, please look info html2text_test.go.