Skip to content
🛠️ToolsShed

Text Columns

Split your text into multiple equal-width columns for easy reading.

About this tool

Text Columns is a simple tool that divides your text into multiple equal-width columns, making long passages easier to read and scan. This layout style, popularized by newspapers and books, reduces eye strain by limiting the width of text on each line and helping readers maintain focus as they move from column to column.

To use the tool, paste your text into the input area and select the number of columns you want. The tool automatically distributes your text evenly across the columns, adjusting the layout to fit your content. This works great for articles, poetry, essays, or any lengthy text you'd like to format for better readability.

Text Columns is particularly useful when preparing content for publication, designing newsletters, or simply reformatting long documents to make them more visually appealing. The multi-column layout also works well on both desktop and mobile views, adapting smoothly to different screen sizes.

Frequently Asked Questions

Code Implementation

import textwrap

def text_to_columns(text: str, num_columns: int, col_width: int = 30) -> str:
    """Split text into N columns with specified column width."""
    lines = text.splitlines()
    wrapped = []
    for line in lines:
        if line.strip():
            wrapped.extend(textwrap.wrap(line, col_width) or [""])
        else:
            wrapped.append("")

    # Pad to fill columns evenly
    rows = -(-len(wrapped) // num_columns)  # ceiling division
    wrapped += [""] * (rows * num_columns - len(wrapped))

    result_lines = []
    for r in range(rows):
        row_parts = []
        for c in range(num_columns):
            idx = c * rows + r
            cell = wrapped[idx] if idx < len(wrapped) else ""
            row_parts.append(cell.ljust(col_width))
        result_lines.append("  ".join(row_parts))

    return "\n".join(result_lines)

text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " * 3
print(text_to_columns(text, num_columns=2, col_width=40))

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.