Escape sequences to line breaks
Convert between literal escape sequences such as \n and real line breaks in both directions, covering \n / \r\n / \r / \t / \\ with LF or CRLF normalisation and replacement counts.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Converted text
Only \n, \r, \t and \\ are handled; everything else is kept untouched.
Enter text to convert its line break notation
What this tool does
- API responses and logs often contain literal \n instead of real line breaks: converting them makes the text readable and countable again.
- Go the other way to fold multi-line text into a single line with escapes, ready for a JSON string, a regex or a code constant.
- Handles \t tabs and \\ double backslashes as well, so text that was already escaped is not mangled twice.
Example
Input
第一行\n第二行
Output
第一行 第二行
The default direction is escape → real line break: one \n becomes one newline, and the reverse direction writes real line breaks back as \n.
Frequently asked questions
Which escape sequences are supported?
\n, \r\n, \r, \t and \\ (a double backslash becomes a single one). Coding escapes such as \u4e2d or \x41 are left alone — those belong to the Unicode escape tools.
Does a double backslash followed by n count as a newline?
No. The matcher recognises \\ first and turns it into a single backslash, leaving the following n as a normal character, so "\\n" stays two characters instead of becoming a newline — exactly the semantics you want inside code.
What is the line break style option for?
It normalises mixed Windows and Unix line breaks to LF or CRLF. With "keep as-is" the \r\n escape becomes a single line break (the CR is not kept); use the style option when you need CRLF specifically.
How is the replacement count computed?
It counts the replacements that actually happened: newlines, tabs and backslashes, in either direction. A \t conversion that is switched off is not counted.
Keywords:escape to newlinenewline escapeliteral backslash n