Align text to left, center, right, or justify with configurable width and padding
- or = for ASCII separator lines (centered text flanked by dashes), * for attention-grabbing banners, . for table-of-contents style dot leaders, or ~ for decorative waves. The aligned result updates instantly as you change settings, and the Copy button transfers the formatted output to your clipboard. All formatting runs entirely in your browser — your text content never leaves your device.Center alignment places text in the middle of the line by adding equal padding to both sides — it never changes the spacing between words. Each line's centering is independent, so lines of different lengths will have their centers aligned but their edges will be ragged on both sides. This produces clean, symmetrical output ideal for titles, headings, and poetry. <strong>Justify alignment</strong> stretches each line to fill the full width by adding extra spaces between words — the left AND right edges are perfectly straight, like a newspaper column. The algorithm works by: (1) calculating how many extra spaces are needed to reach the target width, (2) distributing these spaces evenly between words (with extra spaces going to the leftmost gaps when the distribution isn't even). Justification works best when: lines are close to the target width (within 70–90%) — stretching short lines creates huge word gaps (called 'rivers' in typography); words are relatively short — long words leave fewer gaps to absorb extra space; there are multiple words per line — single-word lines can't be justified. For English text, justification typically looks good at widths of 60–80 characters. The PivaBox Text Aligner runs entirely client-side — your text remains private.
The tool uses JavaScript's <code>.length</code> property which counts UTF-16 code units. This works correctly for most characters but has implications for alignment precision: (1) <strong>CJK characters</strong> — Chinese, Japanese, and Korean characters count as 1 unit in JavaScript but occupy approximately 2 character cells in monospace terminal display (they're 'full-width'). The aligner treats them as 1 character wide, so lines with CJK text may appear misaligned in monospace terminals. For text-heavy CJK alignment, consider using dedicated CJK formatting tools. (2) <strong>Emoji</strong> — many emoji are represented as surrogate pairs (2 UTF-16 code units) and count as 2 characters in <code>.length</code>, but display at varying widths (1–2 cells) depending on the emoji and platform. (3) <strong>Combining characters</strong> — accented characters can be a base character + combining diacritical mark (e.g., 'é' as <code>e</code> + <code>́</code>), counting as 2 code units but displaying as 1 glyph. For most Latin-text alignment tasks, these edge cases are minor. For professional monospace typography requiring pixel-perfect CJK+Latin alignment, specialized terminal formatting libraries are recommended.
Text alignment serves diverse needs across development and content creation: (1) <strong>ASCII art and banners</strong> — center-align text within decorative borders for MOTD (Message of the Day) files, SSH login banners, or retro BBS-style graphics. (2) <strong>Code comments and documentation headers</strong> — create visually structured comment blocks with centered section titles flanked by equals signs or dashes. (3) <strong>Plain-text tables</strong> — right-align numeric columns for correct digit alignment in text-based table generators and CSV previews. (4) <strong>Terminal UI layout</strong> — align status messages, progress bars, and menu items in CLI applications and shell scripts. (5) <strong>Email signatures</strong> — format multi-line signatures with consistent width and alignment for plain-text email clients. (6) <strong>Fixed-width data files</strong> — generate properly padded fields for legacy systems that expect fixed-width record formats. (7) <strong>README badges and shields</strong> — center-align badge rows in GitHub README files. The PivaBox Text Aligner provides instant, private text formatting suitable for all these use cases.