ASCII Code for Enter Key- Complete Reference Guide

What Is the Enter Key ASCII Code?

The Enter key sends two different ASCII characters depending on your operating system. Most people think it's one key, one code. It's not. This trips up beginners and causes bugs in production code.

Here's what you need to know:

The Three Line Ending Standards

Different systems use different line endings. This isn't a preference — it breaks compatibility when systems don't match.

Unix/Linux/macOS

Uses LF only (ASCII 10). A newline is one character. Simple, clean, standard.

Windows

Uses CRLF (ASCII 13 + ASCII 10). Two characters per line break. The legacy of old teletype machines where you needed both carriage return and line feed.

Old Mac Systems (Pre-OS X)

Used CR only (ASCII 13). This is mostly dead now, but you'll see it in legacy file formats.

ASCII Code Reference Table

Name Decimal Hex Binary Used By
CR (Carriage Return) 13 0x0D 00001101 Windows (with LF)
LF (Line Feed) 10 0x0A 00001010 Unix, Linux, macOS
CRLF (Combination) 13, 10 0x0D 0x0A Two bytes Windows protocols

Why This Matters in Practice

If you open a Unix file in Notepad on Windows, you see one long line. No breaks. That's because Notepad didn't handle LF-only line endings until 2018.

If you commit a file with mixed line endings to Git, you'll see the entire file marked as changed. Every. Single. Line.

HTTP headers require CRLF. Email standards require CRLF. Network protocols vary. Understanding which system you're working with saves hours of debugging.

How to Use Enter Key ASCII Codes in Code

JavaScript

Use escape sequences or constants:

"\n" — LF (Unix line ending)
"\r\n" — CRLF (Windows line ending)

Node.js example:

const content = "Line 1\r\nLine 2";

Python

Python handles this automatically with its open() function, but you can force specific modes:

open('file.txt', 'w', newline='\n') — Force Unix line endings
open('file.txt', 'w', newline='\r\n') — Force Windows line endings

C/C++

'\n' — Translates to system default (LF on Unix, CRLF on Windows in text mode)
'\r\n' — Explicit CRLF

HTML

Use <br> for line breaks. The actual ASCII characters don't render in browsers — HTML collapses whitespace by default.

Command Line

When you press Enter in a terminal, the shell sends the line to the program with a line ending. The program sees the raw characters based on your OS.

Common Problems and Fixes

Quick Reference

Enter key ASCII summary: