Table
Swift library for beautifully formatted table output — supports Unicode, CJK, emoji, and os.Logger
Install / Use
/learn @ShawnBaek/TableREADME
Table
Swift library for beautifully formatted table output — supports Unicode, CJK, emoji, and os.Logger.
You can print the table bypassing the Any data!
[e.g., 1d array, 2d array, and dictionary]
It inspired by javascript console.table.
I'm sure if you practice coding interviews, it helps you a lot. You don't need to struggle for checking results using a build-in print function!
Requirements
- Swift 6.1+ (Xcode 16+ or Swift 6.1 toolchain on Linux)
- macOS 11+ / iOS 14+ / tvOS 14+ / watchOS 7+
Usage
import Table
//1D Array of String with Header
print(table: ["Good", "Very Good", "Happy", "Cool!"], header: ["Wed", "Thu", "Fri", "Sat"])
//1D Array of Int
print(table: [2, 94231, 241245125125])
//1D Array of Double
print(table: [2.0, 931, 214.24124])
//2D Array of String
print(table: [["1", "HELLOW"], ["2", "WOLLEH"]], header: ["Index", "Words"])
//2D Array of String, but Length is not equal!
print(table: [["1", "b2"], ["Hellow", "Great!"], ["sdjfklsjdfklsadf", "dsf", "1"]])
//2D Array of Int, but Length is not equal!
print(table: [[1, 2, 3], [4, 5, 6], [7, 8, 9, 10]])
//D.I.C.T.I.O.N.A.R.Y!!
print(table: ["1": 1, 2: "Hellow?", 1.2: 0, "I'm Table": [1, 2, 3, 2, 1]], header: ["key", "value"])
+----+---------+-----+-----+
|Wed |Thu |Fri |Sat |
+----+---------+-----+-----+
|Good|Very Good|Happy|Cool!|
+----+---------+-----+-----+
+-+-----+------------+
|2|94231|241245125125|
+-+-----+------------+
+---+-----+---------+
|2.0|931.0|214.24124|
+---+-----+---------+
+-----+------+
|Index|Words |
+-----+------+
|1 |HELLOW|
+-----+------+
|2 |WOLLEH|
+-----+------+
+----------------+------+-+
|1 |b2 | |
+----------------+------+-+
|Hellow |Great!| |
+----------------+------+-+
|sdjfklsjdfklsadf|dsf |1|
+----------------+------+-+
+-+-+-+--+
|1|2|3| |
+-+-+-+--+
|4|5|6| |
+-+-+-+--+
|7|8|9|10|
+-+-+-+--+
+---------+---------------+
|key |value |
+---------+---------------+
|2 |Hellow? |
+---------+---------------+
|I'm Table|[1, 2, 3, 2, 1]|
+---------+---------------+
|1.2 |0 |
+---------+---------------+
|1 |1 |
+---------+---------------+
Support Distribution
The default distribution is fillProportionally.
print(table: ["Good", "Very Good", "Happy", "Cool!"], header: ["Wed", "Thu", "Fri", "Sat"])
+----+---------+-----+-----+
|Wed |Thu |Fri |Sat |
+----+---------+-----+-----+
|Good|Very Good|Happy|Cool!|
+----+---------+-----+-----+
But It can be set by fillEqually like below
print(
table: ["Good", "Very Good", "Happy", "Cool!"],
header: ["Wed", "Thu", "Fri", "Sat"],
distribution: .fillEqually
)
+---------+---------+---------+---------+
|Wed |Thu |Fri |Sat |
+---------+---------+---------+---------+
|Good |Very Good|Happy |Cool! |
+---------+---------+---------+---------+
SPM Support
The table is only supported SPM (Swift Package Management)

Table Style
Choose between ASCII (default) or Unicode box-drawing characters:
ASCII Style (Default)
print(table: [["1", "Hello"], ["2", "World"]], header: ["ID", "Word"])
+--+-----+
|ID|Word |
+--+-----+
|1 |Hello|
+--+-----+
|2 |World|
+--+-----+
Unicode Style (MySQL-like)
print(table: [["1", "Hello"], ["2", "World"]], header: ["ID", "Word"], style: .unicode)
┌──┬─────┐
│ID│Word │
├──┼─────┤
│1 │Hello│
├──┼─────┤
│2 │World│
└──┴─────┘
Multi-Language Support
Table correctly handles CJK characters, Korean Hangul, Japanese Kana, Arabic, and emoji with proper column alignment:
// Mixed language table with Unicode style
print(table: [
["Hello", "你好"],
["World", "世界"]
], header: ["EN", "CN"], style: .unicode)
┌─────┬────┐
│EN │CN │
├─────┼────┤
│Hello│你好│
├─────┼────┤
│World│世界│
└─────┴────┘
Emoji Support
print(table: ["👋", "🎉", "🚀"], style: .unicode)
┌──┬──┬──┐
│👋│🎉│🚀│
└──┴──┴──┘
Control Character Handling
Control characters are automatically escaped to prevent layout corruption:
print(table: ["Line1\nLine2", "Tab\there"])
// Displays as: |Line1\nLine2|Tab\there|
Logger Integration
Table extends Apple's os.Logger with a table() method for easy logging:
import os
import Table
let logger = Logger(subsystem: "com.myapp", category: "DataDisplay")
// 1D Array of String with Header
logger.table(["Good", "Very Good", "Happy", "Cool!"], header: ["Wed", "Thu", "Fri", "Sat"])
// 1D Array of Int
logger.table([2, 94231, 241245125125])
// 1D Array of Double
logger.table([2.0, 931, 214.24124])
// 2D Array of String
logger.table([["1", "HELLOW"], ["2", "WOLLEH"]], header: ["Index", "Words"])
// 2D Array with unequal columns
logger.table([["1", "b2"], ["Hellow", "Great!"], ["sdjfklsjdfklsadf", "dsf", "1"]])
// 2D Array of Int
logger.table([[1, 2, 3], [4, 5, 6], [7, 8, 9, 10]])
// Dictionary
logger.table(["name": "Alice", "age": 30] as [AnyHashable: Any], header: ["key", "value"])
Logger Options
// Choose table style (default: .unicode)
logger.table(data, style: .ascii) // +--+--+
logger.table(data, style: .unicode) // ┌──┬──┐
// Choose log level (default: .info)
logger.table(data, level: .debug)
logger.table(data, level: .error)
// Choose distribution
logger.table(data, distribution: .fillEqually)
Output in Console.app:
┌─────┬───┐
│Name │Age│
├─────┼───┤
│Alice│30 │
├─────┼───┤
│Bob │25 │
└─────┴───┘
What's the next step?!
I'm going to support more types!
- tuple
- decodable / encodable
- custom data type
Table Style
- ascii table
- dashed table
- and more
Unit Tests
The library uses Swift Testing framework with 25+ test cases covering Unicode handling, performance, and edge cases.
Contributing to Table
Contributions to the Table are welcomed and encouraged!
Contact Me
If you have any questions about Table, please email me at shawn@shawnbaek.com
Related Skills
openhue
344.1kControl Philips Hue lights and scenes via the OpenHue CLI.
sag
344.1kElevenLabs text-to-speech with mac-style say UX.
weather
344.1kGet current weather and forecasts via wttr.in or Open-Meteo
tweakcc
1.5kCustomize Claude Code's system prompts, create custom toolsets, input pattern highlighters, themes/thinking verbs/spinners, customize input box & user message styling, support AGENTS.md, unlock private/unreleased features, and much more. Supports both native/npm installs on all platforms.
