How to Identify Newline Characters in Unicode
Identify LF, CR, CRLF, NEL, Line Separator and other Unicode newline characters by code point, check them with an inspector or command line, and verify the result.
Two line breaks that look the same on screen can be stored as different characters. You need to know which one your text contains when a file splits into the wrong number of lines, a search pattern fails to match, or a diff marks every line as changed. This guide covers what a code point inspection tells you, which Unicode characters act as newlines, and how to identify them and confirm the result without changing meaningful content.
What a code point inspector does for your text
A code point inspector takes any text you paste or load and breaks it into individual characters. For each character it reports the Unicode code point, written as U+ followed by a hexadecimal number. It usually also shows the character name and often the bytes used to store it in an encoding such as UTF-8. Line breaks are invisible or show only as a jump to the next line, so this is the most direct way to see exactly what is there. Inspection only reads the text and does not modify it, so you can run it on a sample safely before deciding whether any conversion is needed.
Output layout differs between tools. Some show control characters with an abbreviation such as LF. Others show a placeholder name. Some list a Windows line ending as two entries and others as one break. No specific tool was evaluated for this guide, so check your tool's documentation for how it labels these characters.
Unicode characters that act as newlines
| Character | Code point | Abbreviation or escape | UTF-8 bytes | Where it commonly appears |
| Line Feed | U+000A | LF, \n | 0A | Linux, macOS and other Unix-like systems |
| Carriage Return | U+000D | CR, \r | 0D | Classic Mac OS (before Mac OS X), legacy files |
| Carriage Return + Line Feed | U+000D U+000A | CRLF, \r\n | 0D 0A | Windows text files, many internet protocols |
| Next Line | U+0085 | NEL | C2 85 | Text converted from EBCDIC-based systems |
| Line Tabulation (vertical tab) | U+000B | VT, \v | 0B | Some word-processor exports |
| Form Feed | U+000C | FF, \f | 0C | Page breaks in plain text |
| Line Separator | U+2028 | LS | E2 80 A8 | Text pasted from some applications and documents |
| Paragraph Separator | U+2029 | PS | E2 80 A9 | Text pasted from some applications and documents |
CRLF is a sequence of two code points, not a single character, so an inspector lists it as CR followed by LF. The Unicode Standard's newline guidelines treat that pair as one line break. Whether VT and FF count as line breaks depends on the software reading the text.
Do not confuse newline characters with visible symbols that represent them. Examples are U+240A SYMBOL FOR LINE FEED, U+2424 SYMBOL FOR NEWLINE and U+21B5 DOWNWARDS ARROW WITH CORNER LEFTWARDS (↵). These are ordinary printable characters and do not break a line.
Step by step: identify the line breaks in your text
- Take a short sample that contains at least one line break, directly from the original file or source. Some editors and clipboards convert line endings when you copy and paste, so read the file itself if you can.
- Run the sample through a code point inspector, or use one of the command-line or code methods below.
- Find the entries between the end of one line and the start of the next, and match their code points against the table above.
- Note whether the breaks are consistent. A mix, such as mostly LF with a few CRLF, usually explains lines being split or merged unexpectedly.
- Only if you need a single style, convert the line endings. Then inspect the result again, as described in the verification section.
Inspect bytes from the command line
On Unix-like systems, od -c prints each byte and shows CR as \r and LF as \n. The example below builds a two-line string with a Windows-style first line ending. The output shown is illustrative of what od typically prints.
printf 'one\r\ntwo\n' | od -c
# Typical output (illustrative):
0000000 o n e \r \n t w o \n
0000011
Multi-byte newlines do not appear as escapes. od -c shows them as octal bytes, so a hexadecimal view is easier to read. With xxd or od -An -tx1, look for c2 85 (NEL), e2 80 a8 (Line Separator) and e2 80 a9 (Paragraph Separator). These byte values apply to UTF-8 only. In UTF-16 files, LF appears as 000A plus the byte order of the file, so read hex dumps with the file's encoding in mind.
List code points with a short Python script
The script below is an example and has not been run here as verified output. It prints the code point and name of every newline-type character in a string. CR, LF, NEL, VT and FF are control characters that have no formal Unicode name, so the script supplies a fallback label.
import unicodedata
NEWLINES = "\n\r\x0b\x0c\x85\u2028\u2029"
text = "one\r\ntwo\u2028three\x85four"
for index, ch in enumerate(text):
if ch in NEWLINES:
name = unicodedata.name(ch, "<control character, no formal name>")
print(index, f"U+{ord(ch):04X}", name)
To inspect a file this way, open it with newline="" so Python keeps the original line endings. For example, use open(path, encoding="utf-8", newline=""). In the default text mode, Python translates CRLF and CR to LF while reading, so CR would never show up in your results. Python's str.splitlines() treats more characters as line boundaries than just LF. These include NEL, Line Separator, Paragraph Separator, VT, FF and the file, group and record separators U+001C to U+001E. This can split text in places you did not expect.
Search for newlines with regular expressions
To find any of the newline characters listed above, use an explicit character class such as [\r\n\x0B\x0C\x85\u2028\u2029], adjusting the escape syntax to your regex engine. PCRE, Perl and Java (version 8 and later) also support \R, which matches any Unicode line break sequence and treats CRLF as a single match. JavaScript does not support \R. In JavaScript, the dot does not match LF, CR, U+2028 or U+2029 unless the s (dotAll) flag is set.
Signs that point to a specific newline character
- ^M at the end of each line in a terminal editor such as Vim usually means CR characters are present, typically from CRLF endings.
- A file that shows as one long line in one program but as many lines in another often uses CR-only or LS line breaks.
- A diff that marks every line as changed when the text looks identical often indicates a switch between LF and CRLF.
- JavaScript code that breaks when embedding JSON text can involve U+2028 or U+2029. These are valid unescaped inside JSON strings, but they were not allowed in JavaScript string literals before ECMAScript 2019.
Verify the result without changing meaningful content
After you convert or remove line breaks, inspect the same sample again and confirm that only the intended code points changed. Count the line breaks before and after. The count should match unless you meant to join lines. Keep in mind that a CRLF to LF conversion changes the byte count while keeping the line count the same.
Watch for text that only looks like a newline. In source code, configuration files and JSON, a backslash followed by n is two ordinary characters (U+005C U+006E), not a line break. An inspector shows them as separate code points, and a tool that rewrites real line breaks should leave them untouched. If you compare files that differ only in CRLF versus LF, GNU diff's --strip-trailing-cr option ignores the trailing CR so that real content differences stand out.
Gaps in this guide
The code points and UTF-8 byte values above come from the Unicode Standard and general, verifiable behavior. No specific inspection tool, version or performance data was evaluated. The sample outputs are illustrative, not captured test results. Before relying on a particular tool's output format or its handling of CRLF, check its documentation or test it on a small known sample.