Registry / data / striprtf

striprtf

JSON →
library0.0.33pypypi✓ verified 23d ago

striprtf is a simple Python library designed to convert Rich Text Format (RTF) files or strings into plain text. It focuses on handling various RTF parsing challenges, including automatic encoding detection (with a default of 'cp1252'), Unicode decoding, and the removal of binary data. The library is currently at version 0.0.29, released on March 27, 2025, and maintains an active release cadence.

pip install striprtf
INSTALL
IMPORT
SIG · STRIPRTF
S
striprtf
datapythonv0.0.33
Install
1.5s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.33 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.008s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.006s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rtf_to_text
from striprtf.striprtf import rtf_to_text

Convert an RTF formatted string directly to plain text. The `rtf_to_text` function is the primary interface. You can specify the encoding if different from the default 'cp1252'.

from striprtf.striprtf import rtf_to_text # Example RTF string (simplified for demonstration) rtf_string = r"""{\rtf1\ansi\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset2 Symbol;}} {\pard\sa200\sl276\slmult1\f0\fs22\lang9081 This is some \b bold\b0 text and some \i italic\i0 text.\par Here is a \ul hyperlink\ul0 : {\field{\*\fldinst HYPERLINK "https://example.com"}{\fldrslt example.com}}\pard\sa200\sl276\slmult1\par """ # Convert RTF string to plain text plain_text = rtf_to_text(rtf_string) print(plain_text) # To convert an RTF file: # try: # with open("your_file.rtf", "r", encoding="cp1252") as f: # rtf_content = f.read() # file_plain_text = rtf_to_text(rtf_content) # print(file_plain_text) # except FileNotFoundError: # print("Error: RTF file not found.") # except Exception as e: # print(f"An error occurred: {e}")
striprtf --version
Debug
Known issues
breakingPython 2 compatibility was dropped after version 0.0.13. The library now explicitly requires Python >=3.8.
fix
Ensure your environment uses Python 3.8 or newer. Upgrade your Python interpreter if necessary.
affects: <=0.0.13 for Python 2 compatibility; >=0.0.14 requires Python 3.8+
gotchaThe `encoding` parameter in `rtf_to_text` defaults to 'cp1252'. If your RTF file uses a different explicit codepage (e.g., 'ansicpg932' for Japanese), the library will attempt to detect it. However, if no explicit codepage is set in the RTF and the content uses a non-default encoding, you must explicitly pass the correct `encoding` parameter (e.g., `encoding="utf-8"`) to avoid decoding errors. An issue where the `errors` parameter was not used was fixed in v0.0.25.
fix
Always check your RTF file's expected encoding. Pass the `encoding` parameter to `rtf_to_text` if it differs from the default or if you encounter decoding issues. For `errors` handling, ensure you are on `v0.0.25` or newer.
affects: All versions, especially prior to v0.0.25 for `errors` parameter.
gotchaThe library is designed for simplicity and may not fully parse or correctly strip all complex or highly malformed RTF structures. While it handles common elements well, very intricate formatting, embedded objects beyond basic images, or severely corrupted RTF might result in incomplete text extraction.
fix
For critical applications with varied or complex RTF inputs, perform thorough testing with representative samples. Consider pre-processing malformed RTF or using more robust, enterprise-grade RTF parsers if full fidelity is required for all RTF complexities.
affects: All versions
Upgrade
Version history
0.0.33latest on PyPI · released Aug 17, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
striprtf — pip install striprtf · libregistry