Skip to content

About

Simple tables in terminal with Go

Topics

Resources

Contributing

Stars

554 stars

Watchers

3 watching

Forks

Latest commit

 

History

116 Commits

Folders and files

Repository files navigation

Simple tables in terminal with Go

simpletable banner

Quality gates Coverage Status Go Reference License

Build readable terminal tables in Go with seven built-in styles, multiline cells, alignment, and column spanning.

Comparison

✅ documented · ⚠️ partial · ❌ not found in sources checked. The last status means the sources checked did not document the feature; it does not establish that the library lacks it. Each symbol links to the public source checked for that comparison.

Feature simpletable termtables uitable tablewriter go-pretty
Multiline cell content ✅ ❌ ⚠️ ⚠️ ❌
Explicit column spans ✅ ✅ ❌ ⚠️ ⚠️
Markdown output ✅ ✅ ❌ ✅ ✅
Alignment controls ✅ ✅ ⚠️ ✅ ✅
Custom table styles ✅ ✅ ❌ ✅ ✅

Sources checked on 2026-11-09. Add a library as a column or a feature as a row, and link each status to the public source checked.

Quick start

package main

import (
	"fmt"
	"strings"

	"github.com/alexeyco/simpletable"
)

func main() {
	table := simpletable.New()
	table.Header = &simpletable.Header{
		Cells: []*simpletable.Cell{
			{Align: simpletable.AlignCenter, Text: "#"},
			{Align: simpletable.AlignCenter, Text: "NAME"},
			{Align: simpletable.AlignCenter, Text: "TAX"},
		},
	}
	rows := []struct {
		name string
		tax  float64
	}{
		{"Newton G. Goetz", 532.70},
		{"Rebecca R. Edney", 1423.25},
		{"John R. Jackson", 7526.12},
		{"Ron J. Gomes", 123.84},
		{"Penny R. Lewis", 3221.11},
	}

	total := 0.0
	for i, row := range rows {
		table.Body.Cells = append(table.Body.Cells, []*simpletable.Cell{
			{Align: simpletable.AlignRight, Text: fmt.Sprintf("%d", i+1)},
			{Text: row.name},
			{Align: simpletable.AlignRight, Text: fmt.Sprintf("$ %.2f", row.tax)},
		})

		total += row.tax
	}
	table.Footer = &simpletable.Footer{
		Cells: []*simpletable.Cell{
			{Align: simpletable.AlignRight, Span: 2, Text: "Subtotal"},
			{Align: simpletable.AlignRight, Text: fmt.Sprintf("$ %.2f", total)},
		},
	}
	table.SetStyle(simpletable.StyleCompactLite)

	for _, line := range strings.Split(table.String(), "\n") {
		fmt.Println(strings.TrimPrefix(strings.TrimRight(line, " "), " "))
	}
}
#         NAME            TAX
--- ------------------ ------------
1   Newton G. Goetz      $ 532.70
2   Rebecca R. Edney    $ 1423.25
3   John R. Jackson     $ 7526.12
4   Ron J. Gomes         $ 123.84
5   Penny R. Lewis      $ 3221.11
--- ------------------ ------------
            Subtotal   $ 12827.02

Install with go get github.com/alexeyco/simpletable.

See the styles demo, multiline example, and column-span example for more.

Benchmarks

(MacBook)

Run these benchmarks using the benchmark instructions.

BenchmarkSimpletable-12             31845             37586 ns/op           34903 B/op        760 allocs/op
BenchmarkTermtables-12              34851             34191 ns/op           24192 B/op        755 allocs/op
BenchmarkUITable-12                  6452            176884 ns/op           55480 B/op       3070 allocs/op
PASS
ok      github.com/alexeyco/simpletable/_example/03-benchmarks-with-others/bench        5.172s

License

MIT

About

Simple tables in terminal with Go

Topics

Resources

Contributing

Stars

554 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages