Skip to tool

Python str.replace() Online

Replace substring occurrences.

The output updates as you type. The tool processes input in your browser.

Worked example

Literal replacement treats punctuation as text. Use the regex replacement tool when the target is a pattern.

Search
"hello"
Replace
"hi"
Count (-1 all)
-1
Sample input
hello world hello
Sample output
hi world hi

Using this operation in Python

The interactive result uses JavaScript. Python str stores Unicode text. Encode to bytes when an API expects UTF-8 or another byte representation.

Python reference