Newline, Line Feed and Enter Character Codes

Line feed is U+000A (decimal 10), carriage return is U+000D (13). Learn how newline codes differ and how text transformations can break them.

"Newline" sounds like one character, but it is not. Depending on the system, a line break is stored as a line feed, a carriage return, the two together, or one of several Unicode separators. That difference rarely matters in everyday typing. It starts to matter when text is reversed, mirrored, restyled, copied between systems or pasted into code. This guide covers the character codes involved, how to identify them, and what common text transformations do to them.

The short answer

The line feed character (LF) is U+000A: decimal 10, hexadecimal 0A, usually written as \n in programming languages. The carriage return (CR) is U+000D: decimal 13, hexadecimal 0D, written as \r. Unix, Linux and modern macOS end lines with LF alone. Windows conventionally uses the two-character sequence CR LF. Classic Mac OS used CR alone. Unicode also defines dedicated separators, U+2028 and U+2029, which are less common in practice.

Line break characters at a glance

Name | Code point | Decimal | Common escape | Typical role
Line Feed (LF) | U+000A | 10 | \n | Line ending on Unix, Linux and modern macOS; the default in most source code and web contexts
Carriage Return (CR) | U+000D | 13 | \r | Line ending on classic Mac OS; first half of CR LF
CR followed by LF | U+000D U+000A | 13, 10 | \r\n | Line ending on Windows; required by many text-based internet protocols
Next Line (NEL) | U+0085 | 133 | none standard | Line ending inherited from EBCDIC mainframe systems; rare elsewhere
Vertical Tab (VT) | U+000B | 11 | \v (in C-family languages) | Treated as a mandatory break by Unicode line breaking rules; rarely used
Form Feed (FF) | U+000C | 12 | \f (in C-family languages) | Page break in older printing contexts; also a mandatory break
Line Separator (LS) | U+2028 | 8232 | none standard | Unambiguous line break within a paragraph
Paragraph Separator (PS) | U+2029 | 8233 | none standard | Unambiguous paragraph break

Why "newline" is a concept, not a code

"Newline" names the idea of ending a line. Each system decides which characters represent it. Many programming languages, file readers and editors translate between conventions automatically. On Windows, for example, a program may write \n and have it stored as CR LF on disk. This translation explains why the same file can look identical in two editors and still differ byte for byte. It is also why a search for "new line unicode" returns several answers: LF is the most common, while U+2028 and U+2029 are Unicode's purpose-built, encoding-neutral options.

The Enter key is not a character code

There is no single "Enter character" in ASCII. The Enter or Return key is a key, not a character, and each application decides what pressing it inserts. Terminals traditionally send CR (13) when Enter is pressed. Text editors and word processors store whatever line ending their platform or settings dictate. Web forms and chat apps may submit the message instead of inserting a break at all. If a reference lists "Enter = 13", it is describing the terminal convention, not a universal rule.

How to identify the line break you have

Because line breaks are invisible, you need a code point inspector, a hex viewer, or an editor that can show whitespace and line endings. In UTF-8, the byte patterns are distinctive:

  • LF: 0A
  • CR LF: 0D 0A
  • CR alone: 0D
  • NEL (U+0085): C2 85
  • Line Separator (U+2028): E2 80 A8
  • Paragraph Separator (U+2029): E2 80 A9

For example, the text "Hi" followed by a Windows line ending and then "there" produces this byte sequence:

48 69 0D 0A 74 68 65 72 65
H  i  CR LF t  h  e  r  e

If an inspector shows an unexpected character, such as a lone 0D at the end of each line or an E2 80 A8 in the middle of a paragraph, the text probably came from a different platform or a rich-text source. That can explain odd spacing after pasting.

What text transformations actually do to line breaks

"Reverse", "mirror" and "font" tools change text in very different ways. It helps to separate tools that change the stored characters from tools that only change how text looks.

Character reversal (stored change)

A tool that reverses the whole string code point by code point also reverses the line break characters and the order of lines. LF on its own survives as LF, but it moves. A trailing newline ends up at the start of the result, and the last line comes first. CR LF is the problem case, because reversing it produces LF CR:

Input code points:     a  b  CR LF c  d
Reversed code points:  d  c  LF CR b  a

Software recognizes CR LF as a single line ending only in that order. LF followed by CR is commonly read as two separate breaks, which shows up as an extra blank line or a stray carriage return. Tools that reverse each line separately, or that normalize line endings before reversing, avoid this. The same naive code point reversal can also detach combining accents from their letters and split multi-code-point emoji. The example above contains neither, but any real input should be checked for both.

Word reversal (stored change)

Reversing word order within each line usually leaves line breaks in place. If the tool treats the entire text as one sequence of words, it may move words across lines or collapse the breaks into spaces. Check a multi-line sample before relying on it.

Mirrored, upside-down and styled "fonts" (stored change)

Tools that substitute look-alike Unicode characters, such as mathematical alphanumeric letters, small capitals or upside-down approximations, have no mirrored or styled version of a line break. Line breaks normally pass through unchanged. Upside-down generators, however, usually also reverse character order, so the line-order and CR LF issues described above apply to them.

CSS presentation (visual only)

On a web page, text can be mirrored with a CSS transform without changing any stored characters. Copying it gives back the original text. Line breaks behave differently in HTML than in plain text. By default, browsers collapse LF and CR into ordinary spaces. A visible break needs a br element or a CSS white-space value that preserves breaks, such as pre-line or pre-wrap. If pasted text with line breaks appears as one long line on a web page, this is usually the cause.

Bidirectional display (visual only)

The Unicode Bidirectional Algorithm treats LF, CR, NEL and U+2029 as paragraph separators. Text direction is worked out again from scratch after each of them. U+2028 is not a paragraph separator for this purpose. This matters when mixing right-to-left and left-to-right text: replacing one kind of line break with another can change how a passage is displayed even though its letters are identical.

Will the result survive copying and sharing?

Line breaks are among the characters most often altered in transit, so anything you share should be checked in the place where it will actually be read. Documented behaviors to watch for include:

  • Line-ending conversion: editors, version control settings and file transfer modes may convert between LF and CR LF, sometimes silently.
  • HTML forms: the HTML standard normalizes line breaks in textarea content. The value seen by scripts uses LF, while submitted form data uses CR LF.
  • Single-line fields: inputs such as titles, usernames and search boxes typically strip line breaks or replace them with spaces.
  • JavaScript and JSON: JSON allows U+2028 and U+2029 inside strings, but JavaScript string literals did not accept them unescaped until the ECMAScript 2019 revision. Older parsers can still fail on them.
  • Search: a phrase split by a line break, or text that has been reversed or replaced with look-alike characters, generally won't match a normal search for the original words.
  • Assistive technology: screen readers read the characters that are actually stored. Reversed or look-alike text is announced reversed, as unusual symbols, or not at all, regardless of how it looks on screen. Visual-only CSS mirroring keeps the underlying text intact.

Each destination handles line breaks its own way, and the evidence for this review does not include tests of specific apps, social platforms or screen readers. A paste that renders correctly in one place shows only that it worked there. Check the actual destination, ideally with a screen reader if accessibility matters.

Is the transformation suitable for your use?

For multi-line text, choose a tool that transforms line by line or normalizes line endings first. The benefit is that the line structure stays recognizable. The tradeoff is the CR LF problem: whole-string reversal can scramble Windows-style breaks into extra or broken lines. Run a short multi-line sample through the tool and inspect the code points before using it on anything important.

Stick with plain, untransformed text, or keep a plain-text copy next to the styled version, when:

  • The text has to be searchable, editable or machine-readable, as with code, data files, configuration or form submissions.
  • Screen reader users need to understand it.
  • It will pass through systems that may change line endings, such as email, version control or cross-platform file sharing.
  • The meaning depends on line order, as with addresses, instructions, poetry or lists.

For purely decorative display on a web page you control, CSS mirroring is usually the safer choice. The stored text, including its line breaks, stays unchanged.

Gaps in this review

The character codes, byte sequences and standards behavior described here are documented in Unicode, HTML and ECMAScript specifications. No specific transformation tool, application, social platform or assistive technology was tested for this article, and no claims are made about any particular tool's privacy or data handling. Verify how your chosen tool and destination handle line breaks before relying on them.