Markdown Table Formatter
Markdown Table Formatter takes the first pipe table in your input and rewrites it with padded, evenly aligned columns, consistent outer pipes and normalised alignment markers (---, :---, ---:, :---:). Short rows are padded with empty cells and a live preview shows the rendered table. Formatting runs in your browser; copy the result or download markdown-table-formatted.md.
使用方法 Markdown Table Formatter
Input Markdown Table
Formatted Output
Preview
コンテンツを読む
Turn a crooked pipe table into a tidy one
Markdown tables render fine even when the source is a mess, but the raw text is a different story. Cells drift out of line, some rows have trailing pipes and some do not, and the separator row is a jumble of dashes and colons. The Markdown Table Formatter fixes the source. Paste a table, click Format, and you get back the same data with every column padded to the same width, every row wrapped in pipes, and a normalised alignment row, plus a rendered preview so you can check the result at a glance.
Formatting changes only spacing and the shape of the separator. Cell text is not rewritten, sorted or reordered, so the table means exactly what it meant before.
Before and after
A typical hand-typed table:
Tool|Language|Stars:---|:---:|---:Pandoc | Haskell|35k|markdown-it|JavaScript|18k|
After clicking Format:
| Tool | Language | Stars || :--- | :---: | ---: || Pandoc | Haskell | 35k || markdown-it | JavaScript | 18k |
Every column is now as wide as its longest entry, the outer pipes are consistent, and the alignment markers survive: the first column stays left aligned, the second centred and the third right aligned. One rule to remember is that separator cells need at least three dashes to be recognised. A row written as :--|:-:|--: is treated as ordinary data, so use three or more dashes per cell and the formatter will take care of the rest.
What the formatter does, rule by rule
- Finds the first table block. It scans from the top for the first line that contains a pipe with text on both sides, then takes every following line until it meets a blank line or a line with no pipe.
- Splits rows into cells. Leading and trailing pipes are dropped, the line is split on every pipe, and each cell is trimmed of surrounding spaces.
- Evens out row lengths. The row with the most cells sets the column count. Shorter rows are padded with empty cells so every row has the same number of columns.
- Normalises the separator. Any row whose cells are all three or more dashes, with optional colons, is rewritten using four standard markers:
---for default,:---for left,---:for right and:---:for centre alignment. - Pads each column. Every column is as wide as its longest cell, with a minimum width of three characters, and shorter cells are padded with spaces on the right.
- Rewraps rows. Each line becomes
| cell | cell | cell |with one space either side of each pipe.
The work happens in your browser using JavaScript on the page. Nothing is sent to the server when you click Format, copy or download.
Reading the screen
The input card is called Input Markdown Table and shows character and line counts underneath. Two small status cards sit to its right: the first switches between No table detected and Table detected as you type, and the second shows the shape as rows × columns. The row figure counts every line in the block, including the separator line. The Formatted Output card holds the result in a read-only editor with its own character and line counts. Below that, the Preview card renders the formatted table as a real HTML table, with the badge changing from Waiting to Preview ready. The first row is shown as the header and the alignment from the separator row is applied to each column.
How to format a table
- Paste your table into Input Markdown Table, or press Paste at the top of the page.
- Confirm the status card says Table detected and that the rows × columns figure looks right.
- Press Format. If no table is found you will see a short warning and the output stays as it was.
- Check the Preview: column headings in the first row, alignment where you expect it, no shifted cells.
- Press Copy Table to copy the result, or Download to save it as
markdown-table-formatted.md. - Paste the formatted table back into your document in place of the old one.
Copy Input copies whatever is in the input editor, and Clear empties input and output and resets the preview.
Important: the output is the table only
You can paste a whole document into the input, and the formatter will find the first table in it. The output, however, contains only that formatted table. Paragraphs, headings and any later tables are not copied to the output. This is by design, since the tool is meant for one table at a time, but it means you should paste the result back into your document yourself rather than replacing the whole file with the output.
If your document has several tables, format them one by one: paste each table on its own, format, copy, and put it back.
Situations where it helps most
- Pull requests and code review. Aligned tables in README files and docs produce cleaner diffs and are easier to review in plain text.
- Tables exported from spreadsheets or chat tools. Converters often emit valid but cramped rows. One pass makes them readable.
- Keeping a consistent house style. Every table ends up with outer pipes, single spaces and the same four separator markers.
- Spotting missing cells. Because short rows are padded with empty cells, a row that was missing a value shows up as an obvious blank in the preview.
Things to avoid
- Escaped pipes and pipes inside code. The formatter splits on every pipe character. A cell like
a \| bor`x | y`is split into two cells, which shifts the rest of the row. Rewrite such cells before formatting or fix them afterwards. - Blank lines inside the table. A blank line ends the block, so rows after it are ignored.
- Two-dash separators. Write at least three dashes per separator cell, otherwise the row is formatted as data.
- Expecting perfect alignment with wide characters. Column width is measured in JavaScript string length. Emoji, Chinese, Japanese or Korean characters take up more screen width than their length suggests, so columns containing them can look uneven in a monospace editor even though the Markdown is valid.
Limitations
- Only the first table block in the input is formatted, and only that table is returned.
- Pipe tables only; HTML tables and other table syntaxes are not recognised.
- A separator row is not required for formatting, but without one the table will not render as a table in most Markdown viewers. The preview still shows the first row as a header.
- Cell content is not escaped, wrapped or shortened. Very long cells make very wide columns.
- No fixed size limit is set in the code; very large tables are limited by your browser's speed and memory.
Related tools
Need a fresh table rather than a cleanup? The Markdown Table Generator creates an empty grid of any size up to 50 rows and 20 columns. If you want tables out of a document altogether, use Markdown Remove Tables.
Frequently Asked Questions
よくある質問
コメント (0)
発生した問題について詳しくご説明ください。調査を行い、ツールの改善に役立てたいと思います。