How to Align Columns of Text Into Neat Tables
Align columns of ragged text by a delimiter so every cell lines up in a monospace grid. Pad CSV, TSV, and config rows, right-align numbers, keep CJK width correct.
How to Align Columns of Text Into Neat Tables
Paste a few rows of name,value pairs into a chat window and they read like a collapsed deck of cards: the second column starts in a different place on every line, and your eye has to hunt for the value you actually care about. The fix is column alignment — splitting each row on a delimiter, then padding every cell with spaces so the columns share a common left or right edge in a monospace font. This is exactly what the Unix column -t command does, and it's what the Column Align tool does in your browser with nothing to install.
This guide walks through how that padding works, when to right-align, how to pick the right delimiter, and the one width detail that trips up almost every online aligner.
What "aligning by a delimiter" actually means
The whole job comes down to one mechanical idea. The tool splits each line on a delimiter — comma, tab, or runs of whitespace — finds the widest cell in each column, and pads every other cell in that column out to the same width. Once every cell in a column is the same display width, the next column starts at the same horizontal position on every row, and the grid snaps straight.
That's the entire trick, but the delimiter choice changes the result. Whitespace mode collapses any run of spaces or tabs into a single separator, which is forgiving when your input has two spaces here and five spaces there. Comma mode treats each comma as a hard boundary, so empty fields survive — a,,b keeps its blank middle cell instead of dropping it. Tab mode is the right pick when you've pasted a real TSV export. The point of choosing a delimiter is to tell the aligner where one cell ends and the next begins; everything downstream is just measuring and padding.
A worked example: ragged name and value pairs
Here is the kind of mess that lands in my terminal a few times a week — a list of items with prices, copied out of some script's output:
banana,3
watermelon,12
fig,1
dragonfruit,45
Every value sits at a different distance from the start of the line, so comparing the numbers means counting commas. Switch the delimiter to comma and align, and the columns square up:
banana 3
watermelon 12
fig 1
dragonfruit 45
The first column is now padded to the width of dragonfruit, the widest name, so the numbers all start in the same place. That's already readable — but the numbers are left-aligned, which is the wrong habit for a value column. We can do better.
Left-align labels, right-align numbers
Alignment direction is a single choice for the whole table, and the rule of thumb is simple: labels read better left-aligned, numbers read better right-aligned. Left alignment pads on the right, so text starts at a clean left edge — exactly how you read a list of names. Right alignment pads on the left, so digits line up by place value under a common right edge, which is how you read a column of money.
Take the same example and switch alignment to right:
banana 3
watermelon 12
fig 1
dragonfruit 45
Now 3, 12, 1, and 45 stack under one right edge, so 45 is visibly the largest at a glance — no counting digits. For a number-heavy list where the last column is the value, right alignment is almost always what you want. Paste the result straight into a fenced code block and Markdown keeps the monospace spacing intact.
The width detail most aligners get wrong
Here's the part that separates a real aligner from a quick String.repeat. In a monospace font, a CJK character — Chinese, Japanese kana, Korean Hangul, full-width punctuation — occupies two cells, not one. If a tool pads by counting characters, a row like 芒果 9 next to apple 1 comes out crooked, because 芒果 is two characters but four cells wide. The tool thinks the cell is narrower than your eye sees it, under-pads, and every column after it drifts.
Column Align counts CJK as width 2 by default, so the padding matches what a real terminal renders. A bilingual roster like 张伟 engineer and Bob designer lines the roles up in the same column instead of staggering them. If you specifically want raw character-count padding, you can turn the switch off — but for any row that mixes East Asian text with Latin text, leave it on. This is the single most common reason an "aligned" block still looks bent, and it's worth knowing even if you never use this particular tool.
Why spaces beat tabs for portability
A reasonable question: why pad with spaces at all, when a tab already jumps to the next column? Because a tab jumps to the next tab stop, and that only lines columns up if every cell is shorter than one tab width. The moment a value overflows, the next field gets shoved a whole stop over and the grid breaks — and the breakage looks different depending on whether the viewer's editor sets tabs to four spaces or eight.
Padding with literal spaces, the way column -t and this tool work, sizes each column to its own widest cell. Alignment then holds no matter how long a value gets, and the block looks identical in any editor, chat client, or wiki regardless of its tab settings. If you genuinely need tab-indented output afterward — say your linter demands tabs — run the space-padded result through a tabs-to-spaces converter in reverse to swap the spacing back. But for pasting a readable grid into a comment or a README, spaces win every time.
I keep this tool open in a pinned tab for exactly that reason. When a teammate drops a wall of comma-separated values into Slack, I paste it in, pick comma, copy the aligned block back, and the conversation moves on without anyone opening a spreadsheet. The column gap field lets me loosen a dense table to two or three spaces between columns when it feels cramped, and the share link reopens the exact view if I want to hand the cleaned-up version back.
A few habits that keep your grids clean
Two small things save the most grief. First, match the delimiter to the data: don't run real CSV through whitespace mode, or empty fields collapse and your rows shift out of register. Second, sort before you align if order matters — aligning doesn't reorder anything, so if you want the rows in a sensible sequence, run them through a text sorter first, then align the sorted result. The two steps compose cleanly because both work line by line.
Column alignment is a tiny operation, but a tidy grid is the difference between data someone scans in a second and data they skip past. Split on the delimiter, pad to the widest cell, pick the alignment that fits the column, and let the tool handle the CJK width so nothing drifts.
Made by Toolora · Updated 2026-06-13