โŒจ๏ธ
โŒจ๏ธ Build CLI Tools with Larz ยท LARZ-801 ยท Session 3 of 5

Beautiful Terminal Output

A tool that prints clear, well-formatted output feels professional and is easier to use. larztui and larzcolor give you tables, panels, rules and colour - width-aware and pipe-safe.

โฑ 7 min read๐Ÿ“… Updated 2026-07-27๐Ÿ“Š Tables, charts & examples

The difference between a script that dumps raw text and a tool that presents clean, formatted output is the difference between something that feels hacky and something that feels professional. larztui and larzcolor give your CLI polished output - aligned tables, bordered panels, titled rules and colour - and crucially, they behave correctly when output is piped or redirected.

Structure and colour

Present information the way it deserves: tables for tabular data, panels for grouped info, colour for emphasis and status.

from larztui import table, panel, rule
from larztui import style

print(rule('Results'))
print(table(['Name', 'Status'], [['build', 'ok'], ['tests', 'ok']]))
print(panel('All checks passed.', title='Summary'))
print(style('done', fg='green', bold=True))
WidgetFor
tableAligned rows/columns of data
panelA bordered box of grouped info
ruleA titled section divider
styleColoured/bold emphasis and status

Well-structured output isn't just prettier - it's genuinely easier to read and act on, which is the whole point of a tool's output.

Correct when it counts

The subtle, important part: output must stay aligned even with colour, and colour must vanish when output isn't a terminal (piped to a file or another command).

๐ŸŽฏ
Width-aware and pipe-safe by default. larztui measures the visible width of text (ignoring colour codes) so tables stay aligned even when cells are styled - a classic bug in naive tools. And colour automatically switches off when output isn't a terminal (or NO_COLOR is set), so piping your tool's output to a file or another command doesn't fill it with garbage escape codes. You get pretty output for humans and clean output for machines, automatically.

Polish your tool

  • Use structure - tables/panels/rules beat walls of text.
  • Use colour for meaning - status, emphasis, warnings.
  • Stays aligned - width measured ignoring ANSI codes.
  • Pipe-safe - colour auto-disables off a terminal.

๐ŸŽฏ Key takeaways

  • Clean, structured output makes a tool feel professional and easier to use.
  • larztui gives tables, panels, rules and colour; use structure and colour to convey meaning.
  • It's width-aware - measures visible width ignoring colour codes - so styled tables stay aligned.
  • Colour auto-disables when output isn't a terminal (or NO_COLOR), keeping piped output clean.

Frequently asked

Why does colour need to disappear when output is piped?

Because colour is produced by invisible ANSI escape codes that a terminal interprets as formatting, but that appear as ugly gibberish (like ^[[32m) when the output goes somewhere that doesn't interpret them - a file, a log, or another program in a pipeline. If your tool always emitted colour, piping its output would corrupt it with these codes, breaking downstream processing. So well-behaved CLIs detect whether output is going to a real terminal and only emit colour then, and also honour the NO_COLOR convention. larztui does this automatically, so your tool is pretty for humans and clean for machines without you having to handle the distinction.

My table columns don't line up when I add colour - why?

Because naive width calculations count the invisible colour codes as if they were visible characters, so a coloured cell looks 'wider' to the code than it appears on screen, throwing off the alignment. The fix is to measure the visible width - the printed characters only, ignoring the ANSI escape sequences - when padding columns. larztui does exactly this, so tables and panels stay perfectly aligned even when cells are styled with colour or bold. It's a small but common bug in hand-rolled table output, and it's handled for you here, which is a big part of why the results look professional.

Session 3 of 5 complete

Next up: Interactive Prompts & Progress

Continue to Session 4 โ†’

Related lessons

More in this course

Course home → · Browse all courses →