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.

runs locally on your browser. Your data never leaves your device.
0Input Length
2Output Length
0Escaped Chars
SingleQuote Style

Common Use Cases

Turn a copied log line or API response into a safely escaped Python string literal
Spot hidden whitespace differences, like stray tabs or Windows-style line endings, that look identical in a plain text box
Generate an unambiguous string literal to paste into a bug report or code review comment
Check exactly how Python would print a string containing quotes, backslashes, or Unicode characters

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.

Frequently Asked Questions

What is Python's repr() function?
repr() returns a printable, unambiguous string representation of an object. For a string, that representation is the same text wrapped in quotes with special characters like backslashes, quotes, newlines, and tabs escaped, so the result could be pasted back into Python source code and evaluated to the original string.
How does this tool decide between single and double quotes?
It follows Python's own rule: the output uses single quotes by default, unless your text contains a single quote character but no double quote, in which case it switches to double quotes instead. This means the quote character wrapping the string almost never needs to be escaped inside it.
How are newlines, tabs, and carriage returns handled?
A newline becomes the two character sequence \n, a carriage return becomes \r, and a tab becomes \t, exactly as Python's repr() renders them. This makes whitespace differences, like a file using Windows-style line endings versus Unix-style ones, immediately visible instead of hidden inside a text box.
What happens to emoji and non-English characters?
Printable Unicode characters, including accented letters, non-Latin scripts, and emoji, are left exactly as typed, matching how Python's repr() treats them. Only genuinely non-printable characters, like control codes or unusual formatting characters, are converted into \x, \u, or \U hexadecimal escapes.
Is this exactly the same output as calling repr() in Python?
It follows the same quote selection and escaping rules Python's string repr() uses, so for ordinary text, code, and Unicode content the output matches character for character. It focuses on strings specifically, rather than the full range of Python object types repr() can also apply to, like lists or custom classes.
Is any of my text uploaded or stored?
No. The conversion runs as plain JavaScript directly in your browser the instant you type or paste. Nothing is ever sent to a server, logged, or stored anywhere, which matters since text pasted into a tool like this often includes sensitive log output or API responses.