Skip to tool

Python Escape string Online

Escape quotes/slashes helper.

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

Worked example

This demo adds backslash escapes to quotes, backslashes, and zero bytes. Use the escaping API for the destination format or protocol when emitting data.

Sample input
John's "note"
Sample output
John\'s \"note\"

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