String Width TS
The definitive Visual Width calculator.
Perfect alignment for Emojis, CJK, and ANSI codes.
📏
Stop Guesstimating Widths
Why your terminal output looks broken, and how to fix it.
❌ The Wrong Way
console.log("Name".padEnd(10) + "Age");
console.log("古川".padEnd(10) + "25");
Name Age
古川 25 <-- Misaligned!
✅ The string-width-ts Way
console.log(padString("Name", 10) + "Age");
console.log(padString("古川", 10) + "25");
Name Age
古川 25 <-- Perfect!
Comparison
| Feature | string-width-ts | string-width | wcwidth |
|---|---|---|---|
| TypeScript | ✅ Native | ⚠️ @types | ❌ No |
| Emoji Support | ✅ Advanced | ✅ Basic | ❌ No |
| String Manipulation | ✅ Pad/Truncate | ❌ No | ❌ No |
| Zero Dependencies | ✅ Yes | ❌ No | ❌ No |
Contribution
We welcome contributions to string-width-ts!
- 1Fork the repository on GitHub
- 2Clone your fork locally
- 3Create a new branch & Commit your changes
- 4Open a Pull Request
License
MIT License
This project is free and open-source software licensed under the MIT License.
Copyright © 2025 Noor Mohammad
☕Support the Project
If this package saves you time, consider buying me a coffee.
Your support helps keep the utilities updated and well-documented. 🙏
Zero dependencies•Type-safe
💝 Thank you for your support!