There are some light and useful python packages for this purpose:

1. tabulate

https://pypi.python.org/pypi/tabulate

from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
Name      Age
------  -----
Alice      24
Bob        19

tabulate has many options to specify headers and table format.

print(tabulate(
    [['Alice', 24], ['Bob', 19]],
    headers=['Name', 'Age'],
    tablefmt='orgtbl'))
| Name   |   Age |
|--------+-------|
| Alice  |    24 |
| Bob    |    19 |

2. PrettyTable

https://pypi.python.org/pypi/PrettyTable

from prettytable import PrettyTable
t = PrettyTable(['Name', 'Age'])
t.add_row(['Alice', 24])
t.add_row(['Bob', 19])
print(t)
+-------+-----+
|  Name | Age |
+-------+-----+
| Alice |  24 |
|  Bob  |  19 |
+-------+-----+

PrettyTable has options to read data from csv, html, sql database. Also you are able to select subset of data, sort table and change table styles.

3. texttable

https://pypi.python.org/pypi/texttable

from texttable import Texttable
t = Texttable()
t.add_rows([['Name', 'Age'], ['Alice', 24], ['Bob', 19]])
print(t.draw())
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

4. termtables

https://github.com/nschloe/termtables

import termtables as tt

string = tt.to_string(
    [["Alice", 24], ["Bob", 19]],
    header=["Name", "Age"],
    style=tt.styles.ascii_thin_double,
    # alignment="ll",
    # padding=(0, 1),
)
print(string)
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

Other options

  • terminaltables - Easily draw tables in terminal/console applications from a list of lists of strings. Supports multi-line rows.
  • asciitable can read and write a wide range of ASCII table formats via built-in Extension Reader Classes.
Answer from iman on Stack Overflow
🌐
Medium
amrinarosyd.medium.com › prettytable-vs-tabulate-which-should-you-use-e9054755f170
PrettyTable vs. Tabulate: which should you use? | by Amrina Rosyada | Medium
May 8, 2023 - If extensive customization and easy column sorting are crucial for you, PrettyTable is the better choice. On the other hand, if simplicity, performance, and a variety of built-in table formats are more important, Tabulate is the way to go.
🌐
Python Central
pythoncentral.io › python-tabulate-creating-beautiful-tables-from-your-data
Python Tabulate: Creating Beautiful Tables from Your Data | Python Central
April 1, 2025 - prettytable: Similar functionality with more styling options · texttable: Focuses on ASCII art tables · pandas.DataFrame.to_string(): Built-in functionality if already using pandas · rich: Advanced console formatting including tables with colors and styles · The tabulate library provides a simple yet powerful way to create beautiful tables in Python.
Top answer
1 of 16
1041

There are some light and useful python packages for this purpose:

1. tabulate

https://pypi.python.org/pypi/tabulate

from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
Name      Age
------  -----
Alice      24
Bob        19

tabulate has many options to specify headers and table format.

print(tabulate(
    [['Alice', 24], ['Bob', 19]],
    headers=['Name', 'Age'],
    tablefmt='orgtbl'))
| Name   |   Age |
|--------+-------|
| Alice  |    24 |
| Bob    |    19 |

2. PrettyTable

https://pypi.python.org/pypi/PrettyTable

from prettytable import PrettyTable
t = PrettyTable(['Name', 'Age'])
t.add_row(['Alice', 24])
t.add_row(['Bob', 19])
print(t)
+-------+-----+
|  Name | Age |
+-------+-----+
| Alice |  24 |
|  Bob  |  19 |
+-------+-----+

PrettyTable has options to read data from csv, html, sql database. Also you are able to select subset of data, sort table and change table styles.

3. texttable

https://pypi.python.org/pypi/texttable

from texttable import Texttable
t = Texttable()
t.add_rows([['Name', 'Age'], ['Alice', 24], ['Bob', 19]])
print(t.draw())
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

4. termtables

https://github.com/nschloe/termtables

import termtables as tt

string = tt.to_string(
    [["Alice", 24], ["Bob", 19]],
    header=["Name", "Age"],
    style=tt.styles.ascii_thin_double,
    # alignment="ll",
    # padding=(0, 1),
)
print(string)
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

Other options

  • terminaltables - Easily draw tables in terminal/console applications from a list of lists of strings. Supports multi-line rows.
  • asciitable can read and write a wide range of ASCII table formats via built-in Extension Reader Classes.
2 of 16
324

Some ad-hoc code:

row_format ="{:>15}" * (len(teams_list) + 1)
print(row_format.format("", *teams_list))
for team, row in zip(teams_list, data):
    print(row_format.format(team, *row))

This relies on str.format() and the Format Specification Mini-Language.

🌐
PyPI
pypi.org › project › tabulate
tabulate · PyPI
>>> print(tabulate(table, headers, tablefmt="presto")) item | qty --------+------- spam | 42 eggs | 451 bacon | 0 · pretty attempts to be close to the format emitted by the PrettyTables library:
      » pip install tabulate
    
Published   Mar 04, 2026
Version   0.10.0
🌐
GitHub
github.com › gregbanks › python-tabulate
GitHub - gregbanks/python-tabulate: fork of https://bitbucket.org/astanin/python-tabulate · GitHub
=========================== ========== =========== Table formatter time, μs rel. time =========================== ========== =========== join with tabs and newlines 22.6 1.0 csv to StringIO 31.6 1.4 asciitable (0.8.0) 777.6 34.4 tabulate (0.7.2) 1374.9 60.9 PrettyTable (0.7.2) 3640.3 161.2 texttable (0.8.1) 3901.3 172.8 =========================== ========== =========== ... 0.7: latex tables. Printing lists of named tuples and NumPy record arrays. Fix printing date and time values. Python <= 2.6.4 is supported.
Starred by 188 users
Forked by 14 users
Languages   Python
🌐
Stack Exchange
softwarerecs.stackexchange.com › questions › 45570 › which-is-the-most-recommended-pretty-print-tables-module-in-python
Which is the most recommended Pretty-print tables module in python? - Software Recommendations Stack Exchange
I have looked at various python modules like tabulate, texttable, terminaltables, prettytable and asciitable. It seemed that tabulate is the most commonly used module but the problem with tabulate ...
Find elsewhere
🌐
Analytics Vidhya
analyticsvidhya.com › home › comprehensive guide to python’s tabulate library
Comprehensive Guide to Python's Tabulate Library - Analytics Vidhya
May 29, 2025 - Learn everything about python's Tabulate category, how to use, what are the different features, applications, examples and more.
🌐
LearnPython.com
learnpython.com › blog › print-table-in-python
How to Pretty-Print Tables in Python | LearnPython.com
When you finish the exploratory data analysis phase, you may want to make your tables look nicer. Two libraries provide the functionality to pretty print comma-separated values (CSV) in Python: tabulate and prettytable.
🌐
Medium
medium.com › top-python-libraries › which-python-library-creates-the-most-stunning-tables-tabulate-vs-prettytable-7efea0101a70
Which Python Library Creates the Most Stunning Tables: Tabulate vs PrettyTable? | by Ajay Parmar | Top Python Libraries | Medium
April 26, 2025 - While both libraries might have drawn inspiration from each other in certain aspects, Tabulate is more streamlined and suited for quicker, simpler coding, while PrettyTable is perfect for projects that require more flexibility and customization.
🌐
GitHub
github.com › astanin › python-tabulate
GitHub - astanin/python-tabulate: Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate. · GitHub
>>> print(tabulate(table, headers, tablefmt="presto")) item | qty --------+------- spam | 42 eggs | 451 bacon | 0 · pretty attempts to be close to the format emitted by the PrettyTables library:
Starred by 2.5K users
Forked by 185 users
Languages   Python
🌐
Arboreus
txt.arboreus.com › 2013 › 03 › 13 › pretty-print-tables-in-python.html
Pretty printing tables in Python
March 13, 2013 - Now tabulate formats data on a per-column basis; per-cell and per-row are also reasonable auto-formatting strategies. Deal with empty cells or occasional textual data in an otherwise numeric column (this may be useful to print tournament cross-tables, for example). ... PrettyTable requires to setup of a pretty-printer in object-oriented style.
🌐
Medium
medium.com › top-python-libraries › tabulate-vs-prettytable-vs-pandas-which-table-formatter-wins-fed73ad3dcd6
Tabulate vs. PrettyTable vs. Pandas: Which Table Formatter Wins? | by Ajay Parmar | Top Python Libraries | Oct, 2025 | Medium
October 22, 2025 - Tabulate vs. PrettyTable vs. Pandas: Which Table Formatter Wins? Comparing PrettyTable, Tabulate, and Pandas for Clean Console Output This article demonstrates the performance, speed, and reliability …
🌐
Towards Data Science
towardsdatascience.com › home › latest › 3 simple ways to quick generate text-based tables in python
3 Simple Ways to Quick Generate Text-based Tables in Python | Towards Data Science
January 20, 2025 - Tabulate is another library I’d like to recommend. Basically, it is pretty similar to PrettyTable, but I think it is more flexible in customizing the grid compared to PrettyTable. We will go through some examples to see how these elements are customized using Tabulate attributes.
🌐
GitHub
github.com › zackdever › python-tabulate
GitHub - zackdever/python-tabulate: github fork of https://bitbucket.org/astanin/python-tabulate · GitHub
===================================== ========== =========== Table formatter time, μs rel. time ===================================== ========== =========== join with tabs and newlines 27.0 1.0 csv to StringIO 38.5 1.4 tabletext (0.1) 529.4 19.6 asciitable (0.8.0) 877.2 32.5 tabulate (0.7.6-dev) 1549.7 57.5 tabulate (0.7.6-dev, WIDE_CHARS_MODE) 2271.5 84.2 PrettyTable (0.7.2) 3986.1 147.8 texttable (0.8.3) 4412.8 163.6 ===================================== ========== =========== ... 0.7: latex tables. Printing lists of named tuples and NumPy record arrays. Fix printing date and time values. Python <= 2.6.4 is supported. ... Contributions should include tests and an explanation for the changes they propose. Documentation (examples, docstrings, README.rst) should be updated accordingly.
Author   zackdever
🌐
Blogger
lino76.blogspot.com › 2016 › 01 › creating-texttables-and-prettytables.html
General: Creating TextTables and PrettyTables using Python
January 21, 2016 - 1. tabulate: https://pypi.python.org/pypi/tabulate · >>> from tabulate import tabulate >>> print tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']) Name Age ------ ----- Alice 24 Bob 19 · tabulate has many options to specify headers and table format. >>> print tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age'], tablefmt='orgtbl') | Name | Age | |--------+-------| | Alice | 24 | | Bob | 19 | 2. PrettyTable: https://pypi.python.org/pypi/PrettyTable
🌐
Abilian
lab.abilian.com › Tech › Python › Useful Libraries › (Pretty) tables in Python
(Pretty) tables in Python - Abilian Innovation Lab
tabulate: tabulate is a library for formatting and printing tables in Python. It can create tables from a variety of data sources, including lists, tuples, and dictionaries. PrettyTable: a simple library to create ASCII tables in Python.