# Line Ending

> The hidden character that ends a line of text. Windows uses two, Linux and macOS use one.

**Field:** Software Development  
**Category:** Files & Formats  
**Also known as:** Newline Character, End of Line, CRLF, LF and CRLF

## Think of it like

Think of it like the Enter key. Some computers press it once, and some press it twice.

## Definition

A line ending is the hidden character that marks where a line of text stops. Linux and macOS use one character, the line feed, written \n. Windows uses two, a carriage return and then a line feed, written \r\n. These two styles are called LF and CRLF. Most editors show them the same. Some tools treat them differently, and that causes odd bugs.

## Example

Lucy edits a script on Windows and runs it on a Linux server. It fails with a strange \r error until she saves it with LF endings.

## Example code

```console
$ printf 'hi\r\n' | od -c
0000000   h   i  \r  \n
0000004
```

This line ends in two hidden characters, a return and a line feed. That is the Windows style.

## Why it matters

Mixed line endings make Git show every line as changed, and they can break scripts. Teams pick one style and stick to it.

## Common mistake

Thinking a change that looks empty is nothing. Often only the line endings changed, and that alone can break a shell script.

## Three principles

- **A hidden mark.** It ends each line of text.
- **Two styles.** LF on Linux and macOS, CRLF on Windows.
- **Pick one.** Set your editor and Git to match.

## Related terms

- [Plain Text File](https://learn.benibix.com/term/development/plain-text-file)
- [Escape Character](https://learn.benibix.com/term/development/escape-character)
- [American Standard Code for Information Interchange (ASCII)](https://learn.benibix.com/term/development/ascii)
- [Git](https://learn.benibix.com/term/development/git)
- [Microsoft Windows](https://learn.benibix.com/term/development/windows)

## Taught in

- [ASCII, Unicode and UTF-8](https://learn.benibix.com/learn/development-formats/ascii-unicode-and-utf-8): File Formats, 8/11

![Three rows, each with a rule, what you mean, and what is stored. Line ending: Hello then a new line is stored as Hello backslash n on Linux and macOS, and Hello backslash r backslash n on Windows. Escape character: a quote inside quotes is typed with a backslash before each inner quote. URL encoding: fish and chips in a link becomes fish%20%26%20chips.](https://learn.benibix.com/diagrams/dev2-escapes.svg)

---

Source: https://learn.benibix.com/term/development/line-ending
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
