Text Replacer

Free Text Replacer for find and replace, including turning \n into line breaks.

.txt2 replacements

Find is literal by default, so \n matches a backslash plus n. With interpret-replace on, \n in Replace becomes a real line break.

Original
Result

Use this Text Replacer to find and replace text without leaving the browser. Paste source on the left, set Find and Replace, and the result updates as you type. Copy or download the output; nothing is uploaded.

Why use Text Replacer?

Literal \n to newlines

Text copied from JSON, logs, or chat often shows \n as two characters. The default replace turns those into real line breaks.

Live result

The right pane updates as you edit Find and Replace, and shows how many replacements were made.

Stays in the browser

Open a local file in Text Replacer, copy the result, or download a .txt file without uploading anything.

The \n you see is often not a newline

When a program wants a line break inside a string, it writes a backslash and an n. JSON does this. Many logs do this. Chat exports, CSV cells, error messages copied out of a browser, and code-generated prompts do this. What lands on your clipboard is four characters of meaning compressed into two glyphs: \n. If you paste that into a notes app, you get a single crushed paragraph with the symbols still visible. Nothing is “wrong” with the text. It is just still escaped.

The same thing happens with tabs (\t), Windows line endings (\r\n), and doubled backslashes from logs that escaped an already escaped string. A text replacer that can interpret those sequences is how you get a document back: real line breaks, real columns, a stack trace you can read. The reverse job exists too—turning a readable draft back into a JSON string—because the next system in the pipeline may only accept the escaped form.

JSON strings, API samples, and copied payloads

You extract a field that looks like "Hello\nWorld" and want it to display as two lines. Literal find of \n, with interpret-escapes on the replacement, is the direct path. People hit this constantly when they copy a value out of a JSON viewer, a Swagger UI, or a log line that quoted the body.

Logs that arrived as one row

Collectors and SIEM exports like to keep an event on a single line. Newlines inside the message get escaped so the file stays one record per row. To read the exception, you need those escapes turned back into breaks. Doing it in the browser is safer than sending the dump to an online “formatter” that will store it.

Chat, CSV, and spreadsheets

Excel and Google Sheets will show a cell that contains line breaks as a single wrapped box, then copy it with \n or with real breaks depending on the app. Chat backups from Slack, Teams, or WeChat often flatten messages. A pass of replacement is cheaper than cleaning 400 rows by hand.

The other direction: encode newlines for code

Sometimes you wrote a readable prompt or an email, and now you need it inside a JSON file, a YAML literal, or a unit-test string. Converting real line breaks to \n (and tabs to \t) is the encode preset. Without it, the JSON you paste will not parse.

Replacement is also how messy text becomes a draft

Not every job is about escapes. Product names change. Staging URLs have to become production URLs. A model wrote “Acme Corp” thirty times and legal wants the real entity. You have a list of IDs in brackets and want them wrapped as markdown links. Find and replace with a live count is the small tool people still open a whole IDE to get.

Prompt and output cleanup

Models emit odd spacing, doubled headings, or HTML entities in otherwise Markdown text. A few literal replacements—straightening quotes, stripping a repeated signature, turning three blank lines into one—make the draft editable before you move it into the MD viewer.

Bulk wording in a pasted document

When the “document” is already on the clipboard, opening Word is overhead. Paste, replace the old brand name or the old API host, glance at the replacement count, copy back. Ignore-case is there because marketing copy is inconsistent about capitalization.

Regex when the pattern is the point

Literal find cannot express “every run of digits” or “the text inside the last pair of quotes.” JavaScript regular expressions can. Capture groups and $1 / $2 in the replacement are how you wrap, reorder, or extract without writing a script. Greedy matching is the default because that is how JS works; turn it off when .* is eating too much and you wanted the shortest match.

Regex mode changes the meaning of \n in the find box: it becomes a real newline, not the two characters backslash and n. If you still need to find the escaped form, search for \\n. That distinction is the usual source of “it didn't match anything.”

Check the options before you trust the output

Find is literal unless you say it is a regex. Replacement inserts what you typed unless you ask it to interpret escapes. Those two switches are independent, which is powerful and easy to mis-set. The live result on the right is the ground truth—watch the count as well as the text. If the count is 0, your find string does not occur. If the count is huge, you may have enabled regex with a pattern that matches empty positions.

Literal find is the safe default

With literal find, \n is a backslash followed by n. That is what you want for JSON-style dumps. Enable regex only when you intend . * + ? and character classes to have meaning. A forgotten regex toggle is how a dot in an IP address starts matching any character.

Interpret escapes only where you need them

On the replacement side, interpret-escapes turns \n into a real line break, \t into a tab, \r into a carriage return, and \\ into a single backslash. Leave it off when you want those characters to stay visible in the output.

Greedy vs lazy is a regex-only problem

.* matches as far as it can. If you are wrapping HTML-ish fragments or quoted strings and the replacement swallowed half the file, disable greedy matching (or write .*? yourself). Literal mode ignores the switch, because there are no quantifiers.

Text Replacer FAQs

In Text Replacer, keep Find as \n and Replace as \n, with “Interpret escapes in replace” turned on. Find stays literal, so it matches the two characters backslash and n. Replace then inserts a real newline.

More tools