wcwidth
Measures the displayed width of unicode strings in a terminal
Decision gist · record as of 2026-08-14
Yes. wcwidth is a stable, actively maintained library (Production/Stable status, recent release) with zero dependencies and broad Python support (3.8–3.15). It solves a real, widespread problem in terminal text handling that affects any CLI tool dealing with Unicode. No known vulnerabilities. The MIT license imposes no restrictions. Install it if your application formats text for terminals and handles non-ASCII characters.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with no runtime dependencies.
- Active maintenance with recent release (46 days ago) and 463 repository stars.
- Supports Python 3.8 through 3.15.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal attribution requirements.
last release 2026-06-29 (46 days) · last repo commit 2026-08-07 · 463 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 306,492,416 downloads/mo, #136 on PyPI
Alternatives
Verify before relying
pip install wcwidth
import wcwidth
# Measure width of a string with emoji
width = wcwidth.wcswidth('♀️')
print(width) # Returns 2
# Measure with terminal-specific corrections
width = wcwidth.wcstwidth('♀️', term_program='vte')
print(width) # Returns 1- Whether terminal-specific corrections via term_program parameter cover all major terminal emulators in practice
- Performance characteristics when processing very large strings or high-volume text streams
What it is and what it does
wcwidth solves a fundamental problem in terminal text formatting: Python's built-in string functions like `str.ljust()`, `str.rjust()`, and `str.center()` measure string width by counting Unicode codepoints, not displayed cells. This breaks for wide characters (CJK, emoji), combining marks, and terminal escape sequences. wcwidth provides POSIX-compliant functions (`wcwidth()`, `wcswidth()`) and higher-level utilities (`width()`, `ljust()`, `rjust()`, `center()`, `wrap()`) that correctly measure displayed width and handle terminal control codes.
The library is designed for CLI and TUI programs that need precise output formatting. It handles complex Unicode (grapheme clusters, emoji with variation selectors, regional indicators), terminal escape sequences (SGR colors, cursor movement, tabs), and can apply terminal-specific corrections when needed. It also provides utilities like `clip()` to extract substrings by column position, `strip_sequences()` to remove escape codes, and iterator functions for navigating grapheme and sequence boundaries—essential for editors and REPLs with cursor control.
Use it for
- Format table columns and aligned output in CLI tools where Unicode content must align correctly
- Implement text wrapping in terminal applications that handle emoji, CJK text, or colored output
- Build REPL or editor cursor navigation that respects grapheme cluster boundaries and escape sequences
- Measure and truncate terminal output to fit within a fixed column width without breaking wide characters
- Strip terminal escape sequences from logged or stored text while preserving semantic width information
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
wcwidth is a stable, actively maintained library (Production/Stable status, recent release) with zero dependencies and broad Python support (3.8–3.15). It solves a real, widespread problem in terminal text handling that affects any CLI tool dealing with Unicode. No known vulnerabilities. The MIT license imposes no restrictions. Install it if your application formats text for terminals and handles non-ASCII characters.
Install
wcwidth on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance with recent release (46 days ago) and 463 repository stars. Supports Python 3.8 through 3.15.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal attribution requirements.
Quickstart
pip install wcwidth
import wcwidth
# Measure width of a string with emoji
width = wcwidth.wcswidth('♀️')
print(width) # Returns 2
# Measure with terminal-specific corrections
width = wcwidth.wcstwidth('♀️', term_program='vte')
print(width) # Returns 1
Verify before relying
- Whether terminal-specific corrections via term_program parameter cover all major terminal emulators in practice
- Performance characteristics when processing very large strings or high-volume text streams
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 46 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 306,492,416 / month, #136 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersNatural Language :: EnglishOperating System :: POSIXProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: InternationalizationTopic :: Software Development :: LibrariesTopic :: Software Development :: LocalizationTopic :: TerminalsTyping :: Typed |
Evidence: wcwidth-0.8.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “unicode terminal width measurement”
- wcwidthMeasures the displayed width of Unicode strings in terminals,…
- cwcwidthcwcwidth provides fast Python bindings for POSIX wcwidth and wcswidth…
- unicode-segmentation-rsProvides Unicode text segmentation (graphemes, words, sentences, line…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also cwcwidth · colored · graphemeu · blessed · reprint · ansimarkup · grapheme · uniseg · rtfunicode · tendo