Tabulate API Reference¶
Auto-generated API documentation for the tabulate module.
tabulate
¶
Tabulate — zero dependencies, stdlib only, Python 3.10+.
Part of zerodep: https://github.com/Oaklight/zerodep Copyright (c) 2026 Peng Ding. MIT License.
Pretty-print tabular data as formatted text tables. Supports multiple output formats (plain, simple, grid, pipe, github, orgtbl, pretty), flexible header modes, column alignment, number formatting, CJK-aware column widths, and various input data shapes.
Example::
from tabulate import tabulate
data = [["Alice", 24], ["Bob", 30]]
print(tabulate(data, headers=["Name", "Age"], tablefmt="grid"))
# +--------+-------+
# | Name | Age |
# +========+=======+
# | Alice | 24 |
# | Bob | 30 |
# +--------+-------+
TableFormat
dataclass
¶
Defines the line/border/separator characters for one table style.
Source code in tabulate/tabulate.py
tabulate(tabular_data, headers=(), tablefmt='simple', floatfmt='g', numalign='decimal', stralign='left', missingval='', showindex=False, colalign=None)
¶
Format tabular data as a pretty-printed text table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tabular_data
|
Any
|
Input data. Accepted shapes: list of lists, list of dicts, dict of lists/values, or any iterable of iterables. |
required |
headers
|
Any
|
Column headers. Can be a list/tuple of strings,
|
()
|
tablefmt
|
str
|
Output format name — one of |
'simple'
|
floatfmt
|
str
|
Format string for float values (passed to |
'g'
|
numalign
|
str
|
Default alignment for numeric columns ( |
'decimal'
|
stralign
|
str
|
Default alignment for text columns. |
'left'
|
missingval
|
str
|
String to display in place of |
''
|
showindex
|
bool | str | Sequence
|
If truthy, prepend row indices. Can be |
False
|
colalign
|
Sequence[str] | None
|
Per-column alignment overrides. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted table as a string. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If tablefmt is not recognised. |
Example::
data = [["Alice", 24], ["Bob", 30]]
print(tabulate(data, headers=["Name", "Age"]))
# Name Age
# ------ -----
# Alice 24
# Bob 30
Source code in tabulate/tabulate.py
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | |