Text Representation
Turn any text into an escaped, quoted string representation, exactly like Python's repr() function, ready to paste into source code or a log line.
Common Use Cases
About Text Representation
Python's built-in repr() function takes any string and turns it into a quoted, escaped representation that could be pasted straight back into source code and evaluated to the exact same string. It's the representation you see whenever Python prints a string inside a list, a dictionary, a traceback, or a debugger, precisely because it makes invisible characters visible: a string containing a tab looks identical to one containing four spaces until you see them rendered as "\t" versus " ". This tool reproduces that exact behavior entirely in your browser, so you can paste in any text, an API response, a log line, a snippet copied from a spreadsheet, and get back the same escaped literal Python itself would print.
The escaping rules this tool follows are Python's own. A backslash becomes a doubled backslash, so the escape sequences themselves stay unambiguous. A newline becomes "\n", a carriage return becomes "\r", and a tab becomes "\t", the three whitespace characters that are functionally invisible in a plain text box but change the meaning of a string entirely, especially when comparing output from two different systems or diagnosing why a file saved on Windows behaves differently from one saved on Linux (carriage return handling is exactly where that difference shows up). Other ASCII control characters below code point 32, along with the DEL character at 127, are rendered as a two digit hexadecimal escape like "\x00" or "\x1f", the same compact form Python uses rather than a longer numeric escape.
Quote selection follows Python's rule exactly rather than always defaulting to one style: the output is wrapped in single quotes unless the text contains a single quote but no double quote, in which case double quotes are used instead, so the quote character itself never needs escaping unless the text contains both kinds. Whichever quote character ends up wrapping the string is the only one escaped inside it, matching character for character what you would get from typing repr("your text") into a real Python interpreter. Unicode text is handled the same way Python's str repr does: printable letters, symbols, accented characters, and emoji are left exactly as typed, since they are already unambiguous and readable, while genuinely non printable Unicode, control characters from other blocks, formatting characters, and unusual separator spaces, are escaped as "\xHH", "\uHHHH", or "\UHHHHHHHH" depending on how large the code point is, the same three escape widths Python's own repr chooses between.
Everything runs as plain JavaScript directly in your browser the moment you type or paste, with no network request involved at any point. That matters here specifically because the kind of text people paste into a tool like this, API keys pulled from a response body, private log output, personal notes, is exactly the kind of content that should never leave your device just to be reformatted. The output box is a plain, read only text field you can copy from with one click, ready to drop into a Python source file, a bug report, or anywhere else an unambiguous, faithfully escaped string literal is useful.