Markdown Soft Wrap vs Hard Wrap: What a Newline Does
Quick answer
Soft wrap is a display setting: your editor folds a long line to fit the window, and the file still holds one line per paragraph. Hard wrap puts real newline characters in the file at a fixed column. In Markdown the rendered result is the same either way, because a single newline inside a paragraph is not a paragraph break.
What one newline means in Markdown
John Gruber's original Markdown defines a paragraph as "one or more consecutive lines of text, separated by one or more blank lines". He points out that this means Markdown supports hard-wrapped text, unlike formatters that turn every line break into a <br />.
The CommonMark spec names the case. A line ending that is not preceded by two or more spaces or a backslash is a soft line break. Conforming renderers may output it as a line ending or as a space, and a renderer may offer an option to render soft breaks as hard ones.
Here is the same paragraph written two ways:
Markdown joins these two lines
into one paragraph.
Markdown joins these two lines into one paragraph.Both render as a single paragraph of running text. The browser decides where to fold it, based on the width of the page.
Soft wrap vs hard wrap in your editor
The two terms get mixed up because they describe different layers: one is about the screen, the other is about the file.
| | Soft wrap | Hard wrap | |---|---|---| | What changes | How the editor displays the line | The characters stored in the file | | Newlines in the file | None added | One at every wrap column | | Window resize | Text reflows | Lines stay where they were | | Rendered Markdown | Same paragraph | Same paragraph |
Soft wrap
With soft wrap the file keeps one long line per paragraph. Resize the window, rotate an iPad or switch from a phone to a desktop and the text reflows to fit. Nothing in the file changes, so editing a sentence in the middle never leaves a ragged line behind.
Hard wrap
With hard wrap, someone (you or a formatter) inserts a newline every 72 or 80 characters. The text looks neat in any viewer that shows raw files, but each edit can leave a short line that you have to reflow by hand. Pandoc's manual lists 72 as its default column width when it wraps output.
When hard wrapping still helps
Soft wrap is the simpler default. Hard wrapping still has one real use: tools that work line by line. A diff shows a changed line as a unit, so a one-word edit inside a 600-character paragraph marks the entire paragraph as changed. With lines of 80 characters the diff points at the sentence you touched. If you review Markdown in Git, see how to diff Markdown files cleanly for another way to tame the output.
Hard wrapping is also easier to read in a terminal or an email client that does not wrap long lines. If neither applies to you, leave the file soft-wrapped.
Forcing a real line break
If you want a visible break inside a paragraph, a newline alone won't do it. End the line with two or more spaces, or with a backslash:
First line\
Second lineBoth produce a hard line break, rendered as <br />. Neither works at the end of a paragraph. The trade-offs between the two are covered in backslash or trailing spaces.
Where renderers differ
Not every place that renders Markdown follows the spec the same way. GitHub's documentation says GitHub renders a line break automatically in issues, pull requests and discussions. In an .md file the same two lines render on one line, and you need two spaces, a backslash or a <br/> tag to split them.
So a note that looks right pasted into an issue can collapse when you save it as a README. Pandoc has a hard_line_breaks extension that treats every newline in a paragraph as a hard break, which is the same behavior as a GitHub issue.
Converting with Pandoc
If you convert Markdown with Pandoc, the `--wrap` option controls how the output source text is wrapped. With auto (the default) Pandoc wraps lines to the --columns width, 72 unless you change it. With none it does not wrap lines at all, and with preserve it tries to keep the wrapping of the source.
pandoc notes.md --wrap=none -o notes-out.mdThis affects the source of the output, not how the finished page looks.
How Carets fits in
Carets is a native notes and code editor for iPhone, iPad and Mac. Your Markdown stays a plain text file, so whichever wrapping style you pick is exactly what is stored and what you can open anywhere. Markdown and plain text sit in the same editor as code, so a README with hard-wrapped lines and a journal with one long line per paragraph live side by side, organized into files, projects and tags.
Carets is built natively for iOS and Mac rather than as a web wrapper, so editing a long note stays quick. Download Carets from the App Store for iPhone, iPad and Mac.
Frequently Asked Questions
Does a single newline create a new line in Markdown?
No. In CommonMark a single newline inside a paragraph is a soft line break. A renderer may output it as a line ending or a space, so the text reads as one paragraph.
Should I hard-wrap Markdown at 80 columns?
Only if your workflow benefits, such as line-based diffs or reading raw files in a terminal. The rendered result is the same either way, so soft wrap is the simpler default.
How do I force a line break in Markdown?
End the line with two or more spaces or a backslash. Both create a hard line break rendered as <br />, but neither works at the end of a paragraph.
Why do my line breaks show up in GitHub issues but not in a README.md?
GitHub renders a line break automatically in issues, pull requests and discussions. In an .md file a single newline stays on one line unless you add two spaces, a backslash or a <br/> tag.