Make TextEdit open in plain text for code
If you opened a .json, .conf, or .env file in TextEdit and it came back with curly quotes and an .rtf extension, TextEdit was in rich-text mode. Switch its default to plain text once — either in TextEdit → Settings or with a one-line Terminal command — and every new document opens as raw, unstyled text that code and config parsers can read.
Why rich text corrupts code
TextEdit ships set to Rich Text Format. That's fine for a letter, but it does three things that quietly break source files. It turns straight quotes "like this" into curly typographic quotes that a shell, JSON parser, or compiler will reject. It can substitute hyphens for en-dashes and add smart list formatting. And when you save, it wraps everything as .rtf — a styled document format — instead of the plain .txt your tools expect. A YAML file with a curly apostrophe or an .rtf payload is no longer valid, and the error you get back rarely points at the quote character as the cause.
Plain-text mode disables all of it. No fonts, no colours, no smart substitutions applied to the document — just the exact bytes you type, saved with the extension you choose.
Set plain text as the default
The menu route sticks for every new document you create from now on:
- Open TextEdit.
- Choose TextEdit → Settings from the menu bar (it's called Preferences on older systems, but Settings on Ventura and later).
- On the New Document tab, under Format, select Plain text.
- Close the window. The next document you open with Cmd+N starts as plain text.
Prefer the command line? This sets the same preference in one line, and the second line puts it back to rich text if you ever want that default again:
# New TextEdit documents open as plain text
defaults write com.apple.TextEdit RichText -int 0
# Undo — go back to rich text as the default
defaults write com.apple.TextEdit RichText -int 1
Quit and reopen TextEdit so it picks up the change. This works the same on macOS 13 Ventura, 14 Sonoma, and 15 Sequoia. It's a per-user setting, so it won't affect other accounts on the Mac.
Turn off smart quotes too
Plain-text mode stops new substitutions being baked in, but TextEdit's system-wide smart quotes and dashes can still fire as you type. For code, kill them: in TextEdit go to Edit → Substitutions and uncheck Smart Quotes and Smart Dashes, or turn them off globally in System Settings → Keyboard → Text Input → Edit. See turning off smart quotes for coding for the full rundown.
Mainspring turns the plain-text default into a labelled, one-click toggle you can flip on or off any time — one of 90+ hidden macOS settings it makes reversible without touching a command line.
Try Mainspring free →Signed & notarized by Apple · 1-day free trial · $29 once
Fix a file that's already open
Changing the default only affects new documents — a config file you opened a minute ago is still rich text. Convert it in place: with the document focused, choose Format → Make Plain Text, or press Shift+Cmd+T. TextEdit warns you it will strip styling; that's exactly what you want. Then Save and give it the right extension. If TextEdit insists on adding .txt, uncheck the extension option in the save sheet, or rename the file afterwards in Finder. From that point the file is clean bytes again, safe to feed to your build, shell, or editor.
When TextEdit isn't the right tool
For anything you edit regularly, a code-aware editor saves headaches. But TextEdit in plain-text mode is perfectly good for a quick fix over SSH or a one-off tweak — and if you live in the shell, nano never adds a byte you didn't type.