ASCII Table Reference

ASCII table reference — decimal, hex, octal, and binary for all 128 characters. Control characters, printable characters, and special symbols in one place.

5 min read

What it is

A command-line tool for generating ASCII tables, useful for displaying data in a human-readable format in the terminal.

Installation

Linux (Debian/Ubuntu):

sudo apt-get update
sudo apt-get install ascii-tables

Linux (Fedora/CentOS/RHEL):

sudo dnf install ascii-tables
# or
sudo yum install ascii-tables

macOS:

brew install ascii-tables

Windows: ascii-tables is not typically available through standard Windows package managers. You may need to:

  1. Install it on a Linux subsystem (like WSL) and run it from there.
  2. Compile from source if you have development tools installed.

Commands / Usage

Basic Table Creation

From comma-separated values (CSV):

echo "Name,Age,City" > data.csv
echo "Alice,30,New York" >> data.csv
echo "Bob,25,London" >> data.csv
echo "Charlie,35,Paris" >> data.csv
ascii-tables data.csv

Generates an ASCII table from a CSV file.

From standard input (piped data):

echo -e "Name\tAge\tCity\nAlice\t30\tNew York\nBob\t25\tLondon" | ascii-tables -

Generates an ASCII table from piped input, using tab as a delimiter by default.

Specifying Delimiters

Using a pipe delimiter:

echo "ID|Status|Timestamp" | ascii-tables -d '|'
echo "101|Success|2023-10-27T10:00:00Z" | ascii-tables -d '|'
echo "102|Failed|2023-10-27T10:05:00Z" | ascii-tables -d '|'

Generates an ASCII table where columns are separated by a pipe symbol.

Using a semicolon delimiter:

echo "Product;Price;InStock" | ascii-tables -d ';'
echo "Laptop;1200.50;true" | ascii-tables -d ';'
echo "Mouse;25.00;false" | ascii-tables -d ';'

Generates an ASCII table where columns are separated by a semicolon.

Table Styles

Using the "plain" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style plain

Generates a table with minimal borders (just lines between rows).

Using the "simple" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style simple

Generates a table with a simple top and bottom border.

Using the "grid" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style grid

Generates a table with full grid borders.

Using the "box" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style box

Generates a table with a box border around the entire table.

Using the "rounded" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style rounded

Generates a table with rounded corners.

Using the "heavy" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style heavy

Generates a table with heavier border characters.

Using the "modern" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style modern

Generates a table with a modern, clean aesthetic.

Using the "markdown" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style markdown

Generates a table formatted for Markdown.

Using the "github" style:

echo "Header1,Header2\nValue1,Value2" | ascii-tables --style github

Generates a table formatted for GitHub Flavored Markdown.

Alignment

Left alignment for all columns:

echo "Name,Score\nAlice,95\nBob,88" | ascii-tables --align left

Aligns all column content to the left.

Right alignment for all columns:

echo "Name,Score\nAlice,95\nBob,88" | ascii-tables --align right

Aligns all column content to the right.

Center alignment for all columns:

echo "Name,Score\nAlice,95\nBob,88" | ascii-tables --align center

Aligns all column content to the center.

Mixed alignment (e.g., left for first, right for second):

echo "Name,Score\nAlice,95\nBob,88" | ascii-tables --align left,right

Specifies alignment for each column, separated by commas.

Column Widths

Fixed width for a column:

echo "ID,Description,Quantity\n1,Widget,100\n2,Gadget,50" | ascii-tables --width 10,20,5

Sets specific widths for columns. If a value exceeds the width, it will be truncated or wrapped depending on other options.

Auto-adjusting widths:

echo "ID,Description,Quantity\n1,Super Widget XL,100\n2,Basic Gadget,50" | ascii-tables

By default, columns will auto-adjust to fit the widest content.

Other Options

No header row:

echo "Alice,30,New York\nBob,25,London" | ascii-tables --no-header

Generates a table without a header row.

Skipping initial lines (e.g., from a file with preamble):

echo "Some preamble text\nHeader1,Header2\nValue1,Value2" | ascii-tables --skip 1

Skips the first line of input before processing it as table data.

Common Patterns

Reading from a file and piping to ascii-tables:

cat my_data.log | ascii-tables

Displays the content of my_data.log as an ASCII table, assuming it’s delimited (e.g., CSV, TSV).

Filtering logs and displaying as a table:

grep "ERROR" application.log | awk '{print $1, $3, $5}' | ascii-tables -d ' '

Finds lines with "ERROR" in application.log, extracts specific fields using awk (space-delimited), and displays them as an ASCII table.

Combining ls output into a table:

ls -l | grep '^-' | awk '{print $9, $5, $7}' | ascii-tables -d ' ' --align left,right,left

Lists files in a long format, filters for regular files, extracts filename, size, and modification date, then displays them in a formatted table.

Generating a table from a JSON array (requires jq):

jq -r '.[] | [.name, .age, .city] | @csv' users.json | ascii-tables -d ','

Uses jq to extract data from a JSON file into CSV format, then pipes it to ascii-tables for display.

Gotchas

  • Delimiter Detection: ascii-tables tries to auto-detect delimiters, but it’s not foolproof. Explicitly setting the delimiter with -d is often more reliable, especially with complex data or if your data contains multiple potential delimiters.
  • Empty Input: If you pipe empty input or provide an empty file, ascii-tables might produce unexpected or no output.
  • Quoting: If your data fields contain the delimiter character, you might need to ensure they are properly quoted in the input source (e.g., CSV) or escape them if piping directly. ascii-tables itself doesn’t have robust quoting/escaping handling for input parsing beyond what the OS shell provides.
  • Unicode/Special Characters: While ascii-tables is designed for ASCII, some terminals and styles might render extended characters inconsistently. The "plain" and "simple" styles are generally safer for maximum compatibility.
  • Large Datasets: For very large files, performance might degrade. It’s primarily intended for displaying moderately sized datasets for human readability.