MainspringGuides › Create .txt Files
macOS Guide

How to Create a .txt File on Mac

Updated July 2026 · 3 min read

You need a genuine .txt file — for a config, a server, a script that's picky about formats — and TextEdit keeps handing you .rtf. The fix is knowing which mode TextEdit is in, or skipping the question entirely with one Terminal command. Both routes, plus the settings that stop the problem recurring.

The TextEdit route

  1. Open TextEdit (Spotlight: Cmd + Space, type "textedit") and press Cmd + N for a new document.
  2. Look at the top of the window. A ruler and formatting bar means rich text mode — press Shift + Cmd + T (Format → Make Plain Text) to switch. No ruler, you're already plain.
  3. Type your content and press Cmd + S. Name the file; plain documents save as .txt. The save dialog's checkbox "If no extension is provided, use .txt" handles the extension for you.

Why macOS keeps giving you .rtf: TextEdit defaults to rich text for new documents, and rich text saves as RTF. If you make text files often, change the default once — TextEdit → Settings… → New Document → Format: Plain Text — and the Shift + Cmd + T step disappears from your life. The full walkthrough is in making TextEdit default to plain text.

The Terminal route: instant and empty

# create an empty text file on the Desktop
touch ~/Desktop/notes.txt

# undo: remove the file
rm ~/Desktop/notes.txt

touch creates the file if it doesn't exist and leaves it untouched if it does — there's no way to clobber content with it. To create and immediately edit in one motion, use open -e ~/Desktop/notes.txt after the touch (opens in TextEdit), or edit right in the Terminal with nano ~/Desktop/notes.txt — write, then Ctrl + O to save and Ctrl + X to exit.

Confirm what you actually saved

By default Finder hides extensions, so notes.txt and notes.rtf can both display as "notes". Turn extensions on and the ambiguity disappears:

  1. In Finder, choose Finder → Settings… → Advanced.
  2. Check Show all filename extensions.

The same setting as a Terminal command:

# show all filename extensions in Finder
defaults write NSGlobalDomain AppleShowAllExtensions -bool true && killall Finder

# undo: hide extensions again
defaults write NSGlobalDomain AppleShowAllExtensions -bool false && killall Finder

For a single suspicious file, select it and press Cmd + I — the Get Info panel's Name & Extension field tells the truth regardless of what Finder displays.

Which route when

Creating a file with content in one line

When the content is short and known, skip the editor entirely and write the file with shell redirection:

# create notes.txt containing one line
echo "backup runs at 02:00" > ~/Desktop/notes.txt

# append another line without overwriting
echo "verified 2026-07-16" >> ~/Desktop/notes.txt

# undo: remove the file
rm ~/Desktop/notes.txt

Mind the arrows: a single > replaces the file's entire contents, while >> appends to the end. Pointing > at a file you meant to keep is the classic way to lose it — when in doubt, append. What macOS notably lacks is a Finder right-click → New Text File like Windows offers; if you want that, it can be built in about two minutes with Automator — see creating text files from Finder.

Last sanity check for files headed to a server or a script: plain text still has encodings and line endings. TextEdit saves UTF-8 by default, which is what nearly everything expects, and Unix-style line endings come standard from both TextEdit and the shell — so files made by any route on this page will behave. Files that arrive from old Windows tools are the ones that occasionally need cleanup.

Skip the Terminal

Show-all-extensions is exactly the kind of setting Mainspring handles in one click — 90+ hidden macOS toggles, labelled and reversible, no defaults commands to remember.

Try Mainspring free →

Signed & notarized by Apple · 1-day free trial · $29 once