explaingit

olekukonko/tablewriter

4,789GoAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Go library that generates formatted plain-text tables for CLI tools, supporting ASCII, Unicode, Markdown, HTML, and ANSI color output with automatic column alignment and width adjustment.

Mindmap

mindmap
  root((tablewriter))
    Output Formats
      ASCII borders
      Unicode box chars
      Markdown syntax
      HTML tables
    Styling
      Cell merging
      Column alignment
      Custom borders
      ANSI colors
    Data Input
      String slices
      Go structs
      CSV source
      SQL nullable types
    Streaming Mode
      Ocean API
      Row by row
      Large datasets
    Versions
      v0.0.5 stable legacy
      v1.1.4 current
      Generics support
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Display query results or structured data in a CLI tool with aligned columns and borders

USE CASE 2

Render Markdown-compatible tables for documentation generators or README output

USE CASE 3

Stream large datasets row by row to a terminal without loading everything into memory

USE CASE 4

Output colorized or Unicode-styled tables in interactive terminal applications

Tech stack

GoUnicodeANSICSVSQL

Getting it running

Difficulty · easy Time to first run · 5min

go get github.com/olekukonko/tablewriter. Use v1.1.4+ for generics and streaming, skip v1.0.0 (missing features). v0.0.5 for legacy projects.

MIT license, free to use, modify, and distribute in personal or commercial projects with no restrictions beyond keeping the license notice.

In plain English

Tablewriter is a Go library that generates formatted tables in plain text. If you are building a command-line tool and want to display data in neat rows and columns rather than raw comma-separated output, this library handles the formatting work for you. You give it rows of data, and it draws the borders, aligns the columns, and adjusts widths automatically. The library supports several output formats beyond basic ASCII: Unicode box-drawing characters for cleaner terminal output, Markdown table syntax for documentation, HTML tables for web output, and ANSI color codes for colorized terminals. There is also a streaming mode called Ocean that renders rows as they arrive rather than waiting for all data to be loaded into memory first, which is useful when working with large datasets. Styling options include merging adjacent cells that share the same value, setting per-column or per-cell alignment, controlling which borders and separator lines appear, and replacing the default border characters with custom ones. The README demonstrates a playful example using emoji as table corners. For data input the library accepts plain string slices, Go structs, or data from a CSV source, and it handles Go's nullable database types from the standard sql package without extra conversion. Two version lines exist. Version 0.0.5 is described as the stable legacy release, suitable for existing projects. Version 1.1.4 and later is the current line and adds generics support along with the newer streaming APIs. Version 1.0.0 is explicitly flagged in the README as missing functionality and should be skipped. The project is open source under the MIT license.

Copy-paste prompts

Prompt 1
I have a Go slice of string slices representing tabular data. Using github.com/olekukonko/tablewriter, write code to render it as a Unicode box-drawing table to os.Stdout with center-aligned headers and right-aligned numeric columns.
Prompt 2
Using tablewriter v1.1.4 generics API, show me how to render a Go struct slice as a formatted CLI table, mapping struct fields to column headers automatically.
Prompt 3
Write a Go example using tablewriter's Ocean streaming API to render rows from a database cursor one at a time, without buffering all rows in memory first.
Prompt 4
Using tablewriter, generate a Markdown-formatted table from a CSV file and print it to stdout so it can be pasted directly into a GitHub README.
Prompt 5
Show me how to configure tablewriter to merge adjacent cells with identical values in a column and apply per-cell ANSI color codes to highlight specific rows.
Open on GitHub → Explain another repo

← olekukonko on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.