Markdown Hard Line Breaks: Backslash vs Trailing Spaces
To force a line break in Markdown, end the line with a backslash or with two or more spaces, then press return. Both give you a <br /> in CommonMark. The backslash is visible and survives editors that trim whitespace; the spaces are invisible and often vanish. Leave both off and a single newline does nothing visible, while a blank line starts a new paragraph.
The two-space rule is the older one. John Gruber's original Markdown syntax notes say that to insert a <br /> you "end a line with two or more spaces, then type return". The backslash form came later, with CommonMark, which calls it "a more visible alternative".
Quick answer
Here is the same two-line paragraph written three ways. In the second block, ␣␣ stands for two real space characters you cannot see.
First line
Second lineFirst line␣␣
Second lineFirst line\
Second lineThe first block renders as one line of text, because the newline is only a soft break. The second and third render "First line", a line break, then "Second line".
Step-by-step
Soft breaks: what you get with no marker
A line ending that has no trailing spaces and no backslash is a soft break. The CommonMark spec says a renderer may output it as a line ending or as a space, and the result looks the same in a browser. It also strips spaces at the end of one line and the start of the next. So hard-wrapping your source at 80 columns is safe. The paragraph still flows as one block.
Method 1: two or more trailing spaces
Type two spaces (more is fine) right before the newline:
Roses are red,␣␣
violets are blue.CommonMark treats the line ending as a hard break, and leading spaces on the next line are ignored, so indenting the follow-up line does no harm. The weakness: you can't see the spaces. Plenty of editors and Git hooks strip trailing whitespace on save, and when they do, your break turns back into a soft break without any warning.
Method 2: a backslash
Put a backslash as the last character on the line:
Roses are red,\
violets are blue.Same hard break, but easy to spot when you reread the file. Nothing trims it. It is part of both CommonMark and the GitHub Flavored Markdown spec, though not of Gruber's original description, so a very old or minimal parser may print the backslash as text. If you do not know which parser will read your file, test a sample first. For how stray spaces and tabs are read in other places, see how CommonMark reads tabs and spaces.
Method 3: a <br> tag as a fallback
GitHub's documentation lists a third option for .md files: an HTML <br/> at the end of the first line. It works where raw HTML is allowed, but it puts markup into text you wanted to keep plain, and some renderers strip raw HTML. Treat it as a fallback.
Common problems and fixes
The break is at the end of a block
Neither method does anything on the last line of a paragraph or heading. The spec's examples show foo\ at the end of a paragraph rendering as the literal text foo\, while foo plus two trailing spaces renders as plain foo. The same goes for ### foo\. A hard break only separates content inside a block, so there must be a line after it.
Code spans and HTML tags
Hard breaks do not occur inside code spans. A backslash and newline inside backticks stays as \ followed by a space, and trailing spaces there become a single space. If you need separate lines of code, use a fenced code block, where every line stays exactly as typed.
Different results on GitHub
GitHub renders line breaks automatically in issues, pull requests and discussions, but not in .md files, per the GitHub Docs on line breaks. That is why a snippet can look right in a comment and run together in a README. Write for the .md case and add a backslash or two spaces.
Trailing spaces get stripped
If your breaks keep disappearing, switch to the backslash. It's the quickest fix. Also check that a line with a break is not accidentally indented four spaces, which can turn it into code; the article on how four spaces can turn a line into code covers that. And if your lines are list items, the bullet markers in Markdown lists article shows how list syntax interacts with the text on the following lines.
Doing this with Carets
Carets is a fast, native notes and code editor for iPhone, iPad and Mac, and your notes stay as plain Markdown files. That matters here: the backslash method is part of the file itself, so a break you write on your Mac still holds when you open the same file on your iPhone, and no tool has to remember hidden whitespace for you. Syntax highlighting makes a trailing backslash easy to spot while you edit, and files, projects and tags keep your Markdown notes organized. Try it on your next multi-line note: download Carets for iPhone, iPad and Mac.
Frequently Asked Questions
How do I add a line break in Markdown?
End the line with two or more spaces or a backslash, then press return. Both produce a <br /> in CommonMark. A blank line starts a new paragraph instead.
Why is my Markdown line break not working?
Common causes: only one trailing space, an editor that strips trailing whitespace, a break placed on the last line of a paragraph or heading, or a renderer that does not follow CommonMark. Try the backslash form first.
Is a backslash line break standard Markdown?
It is part of CommonMark and GitHub Flavored Markdown. Gruber's original description mentions only the two-space method, so older parsers may show the backslash as text.
Should I use a br tag instead?
A <br> tag works in many renderers but mixes HTML into plain text, and some renderers drop raw HTML. Use it as a fallback.