Blockify a String
Convert any text into ASCII or Unicode box art. Create bordered text blocks for code comments, README files, and terminal displays.
About
Box-drawing characters emerged from the CP437 codepage era when terminals needed visual structure without bitmap graphics. The challenge lies in calculating uniform padding: each line must match the longest line's width, then receive border characters at precise offsets. A single miscalculation produces misaligned corners. This tool implements proper Unicode box-drawing sets (U+2500 - U+257F) alongside ASCII fallbacks for legacy systems. Multi-line handling splits at w characters while respecting word boundaries - breaking mid-word creates unreadable output. Shadow effects use block elements (āāā) offset by 1 character position, simulating depth on a 2D plane.
Common failure modes: tabs render inconsistently across systems (some expand to 4 spaces, others 8), and Unicode boxes break in terminals lacking font support. The ASCII mode (+, -, |) guarantees rendering on any system manufactured after 1970. Pro tip: for code comments, use double-line borders (āāā) to distinguish headers from single-line dividers.
Formulas
The blockification algorithm computes the required box dimensions from input text properties:
where Wbox is total box width, p is horizontal padding (spaces between text and border), and 2 accounts for left and right border characters.
where n is number of content lines and pv is vertical padding (empty lines above and below text).
Line padding formula for uniform width:
Shadow offset calculation (applied to border bottom and right):
Word-wrap boundary detection uses greedy algorithm: split at last space before w characters, or force-break if no space exists within limit.
Reference Data
| Style | Top-Left | Top-Right | Bottom-Left | Bottom-Right | Horizontal | Vertical | Use Case |
|---|---|---|---|---|---|---|---|
| ASCII Simple | + | + | + | + | - | | | Maximum compatibility, legacy systems |
| Unicode Light | ā | ā | ā | ā | ā | ā | Modern terminals, clean aesthetic |
| Unicode Double | ā | ā | ā | ā | ā | ā | Section headers, emphasis |
| Unicode Rounded | ā | ā® | ā° | ⯠| ā | ā | Friendly UI, chat bubbles |
| Unicode Heavy | ā | ā | ā | ā | ā | ā | Bold statements, warnings |
| Unicode Double-Single | ā | ā | ā | ā | ā | ā | Mixed emphasis, subtitles |
| Unicode Single-Double | ā | ā | ā | ā | ā | ā | Alternative mixed style |
| Hash Box | # | # | # | # | # | # | Comment blocks, shell scripts |
| Asterisk Box | * | * | * | * | * | * | C-style block comments |
| Equals Box | + | + | + | + | = | | | Section dividers |
| Block Full | ā | ā | ā | ā | ā | ā | High visibility, banners |
| Block Medium | ā | ā | ā | ā | ā | ā | Shaded borders |
| Block Light | ā | ā | ā | ā | ā | ā | Subtle shading |
| Braille Dots | ⣿ | ⣿ | ⣿ | ⣿ | ⣿ | ⣿ | Decorative, accessibility |
| Emoji Box | š² | š² | š² | š² | š² | š² | Social media, casual |