Skip to main content

A simple library to convert rtf to text

Project description


Build status


This is a simple library to convert rtf files to python strings. A lot of medical documents are written in rtf format which is not ideal for parsing and further processing. This library converts it to plain old text.

How to use

from striprtf.striprtf import rtf_to_text
rtf = "some rtf encoded string"
text = rtf_to_text(rtf)

If you want to use a different encoding than cp1252 you can pass it via the parameter encoding. This is only taken into account if no explicit codepage has been set.

from striprtf.striprtf import rtf_to_text
rtf = "some rtf encoded string in latin1"
text = rtf_to_text(rtf, encoding="latin-1")

Sometimes UnicodeDecodingErrors can happen because of various reasons. In this case you can try to relax the encoding process like this:

from striprtf.striprtf import rtf_to_text
rtf = "some rtf encoded string"
text = rtf_to_text(rtf, errors="ignore")

How to use online

If you don't want to install, there is also an online version available at which can be used for free.


Pyth was not working for the rtf files I had. The next best thing was this gist:

~~Very few additions where made, e.g. better formatting of tables. ~~

In the meantime some encodings bugs have been fixed. :-)

Pushing to PyPi

  • pip install twine

Run commands

python sdist bdist_wheel
twine upload -r testpypi dist/*
twine upload -r pypi dist/*

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

striprtf-0.0.26.tar.gz (6.3 kB view hashes)

Uploaded source

Built Distribution

striprtf-0.0.26-py3-none-any.whl (6.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page