---
title: "What is line ending rules (CRLF vs LF)?"  
description: "What is line ending rules (CRLF vs LF)?"  
author: "Anubhav Sharma"  
published: 2026-02-01  
updated: 2026-02-01  
canonical: https://www.mindstick.com/interview/34447/what-is-line-ending-rules-crlf-vs-lf  
category: "website & mobile applications"  
tags: ["application"]  
reading_time: 2 minutes  

---

# What is line ending rules (CRLF vs LF)?

**Line ending rules** define how a new line is represented at the end of each line in a text file.

In short:

- **LF (Line Feed –** `\n`**)**\ Used by **Linux and macOS**
- **CRLF (Carriage Return + Line Feed –** `\r\n`**)**\ Used by **Windows**

### Why it matters

Different operating systems use different line endings. If not handled properly, this can cause:

- Unnecessary Git diffs
- Merge conflicts
- Build or script errors

### How Git helps

Using `.gitattributes`, Git can:

- Store files with **LF** in the repo
- Automatically convert to **CRLF** on Windows checkouts (if configured)

This keeps code consistent across platforms.

## Answers

### Answer by Anubhav Sharma

**Line ending rules** define how a new line is represented at the end of each line in a text file.

In short:

- **LF (Line Feed –** `\n`**)**\ Used by **Linux and macOS**
- **CRLF (Carriage Return + Line Feed –** `\r\n`**)**\ Used by **Windows**

### Why it matters

Different operating systems use different line endings. If not handled properly, this can cause:

- Unnecessary Git diffs
- Merge conflicts
- Build or script errors

### How Git helps

Using `.gitattributes`, Git can:

- Store files with **LF** in the repo
- Automatically convert to **CRLF** on Windows checkouts (if configured)

This keeps code consistent across platforms.


---

Original Source: https://www.mindstick.com/interview/34447/what-is-line-ending-rules-crlf-vs-lf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
