Caxton
Features Benchmarks Pricing Docs How it works Changelog Support About Download Free
Guides
All guides Large File Text Editors EmEditor for Mac UltraEdit Alternatives Notepad++ Alternatives Notepad for Mac Free Text Editors for Mac File Too Large for VS Code CSV Editor for Mac Open a CSV File CSV Viewer for Mac Open a TSV or Pipe-Delimited File Edit CSV Without Auto-Formatting Repair a Malformed CSV Remove Duplicate Rows Validate a CSV Transform a CSV Column Fixed-Width to CSV Change a CSV Delimiter Split a Large CSV Combine CSV Files Sort a Large CSV CSV Too Big for Excel Open a Huge CSV Log Viewer for Mac View Log Files Follow a Live Log File CMTrace for Mac Open a 10 GB Log Filter Large Log Files Jump to a Time in a Log Find & Replace in Huge Files Find & Replace Across Files Regex Cheat Sheet Compare Two Text Files Open a SQL Dump Fix Garbled Text & Encoding Convert a File to UTF-8 Remove a BOM Convert Line Endings Remove Invisible Characters Smart Quotes to Straight Quotes Sort & Dedupe Lines Open a GBK or Big5 File Open a UTF-16 or Shift-JIS File Open a Large JSON File Numbers File Too Large

How to convert smart quotes to straight quotes on a Mac.

You paste a command from a document into Terminal, and it fails with a message about a file that does not exist. A JSON file that looks correct will not parse, or a script reports an invalid character on a line that reads perfectly well. The usual cause is a pair of quotation marks that an app curled while the text was being typed. This guide explains what smart quotes are and why they break code, gives the steps from Apple's own documentation for turning them off, and shows how to convert the ones that are already in a file.

Download Caxton for Free · 7-day free trial of Caxton Pro, no credit card required · 8 MB · macOS 13.0+

The short answer

To convert smart quotes that are already in a file, use perl, which is already installed on a Mac: one command in Terminal rewrites the curly single and double quotes as straight ones. To stop new ones from appearing, turn off the setting named Use smart quotes and dashes in System Settings, under Keyboard and then Text Input. Caxton, a native Mac editor for text and data files, converts them with Text ▸ Clean Up ▸ Straighten Quotes, which shows a count and samples in a preview first and applies the change as one undo step.

What are smart quotes?

Smart quotes are the curved quotation marks that an app puts in place of the straight ones as you type. Apple's macOS User Guide lists the feature among its automatic replacements, where an app can "replace straight quotes with “curly” quotes (called smart quotes)." The quote key on a keyboard types two characters, the straight single quote and the straight double quote. The curly forms are four other characters, each with its own code point in Unicode.

The characterIts name in the Unicode chartIts code point
'Apostrophe, which is the straight single quote.U+0027
"Quotation mark, which is the straight double quote.U+0022
‘Left single quotation mark.U+2018
’Right single quotation mark, which the chart also calls "the preferred character to use for apostrophe."U+2019
“Left double quotation mark.U+201C
”Right double quotation mark.U+201D

Curly quotes are correct typography for prose, and nothing in this guide is a reason to take them out of an essay or a letter. The trouble starts when text that was typed as prose is used as code or as data.

Why do smart quotes break code, JSON, CSV files and Terminal commands?

A language or a file format that a program reads names the exact characters it accepts as quotes, and it names the straight ones. To a parser, a curly quote is an ordinary character that only looks like a quote. Each example below was run on macOS 27 with tools from Apple, and the output shown is what they printed.

Curly quotes in code

Here is a one-line Python script, hello.py, typed with smart quotes on:

print(“backup finished”)

Running it with python3 hello.py stops at the first quote, and the last line of the error is:

SyntaxError: invalid character '“' (U+201C)

On a Mac, python3 comes with Apple's command line developer tools.

Curly quotes in JSON

RFC 8259, the standard for JSON, states that "A string begins and ends with quotation marks," and its grammar defines the quotation mark as the one character %x22, the straight double quote. Here is settings.json with curled quotes:

{“name”: “report”, “pages”: 12}

Python's JSON tool, run as python3 -m json.tool settings.json, refuses the file:

Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

Curly quotes in a Terminal command

In a shell, the straight quotes do a job. The zsh manual page on macOS describes "All characters enclosed between a pair of single quotes" as quoted, and it has its own rules for text "Inside double quotes." A curly quote has no such role. The shell splits the phrase at its spaces and passes the curly quotes along as part of the words. With a log file named system.log, the correct command finds its line:

grep "disk full" system.log
Nov 16 09:14:02 disk full on /Volumes/Data

The same command with curled quotes fails:

grep “disk full” system.log
grep: full”: No such file or directory

grep searched for “disk and took full” for the name of a second file. Some commands do not fail at all. In an empty folder, these two commands run without an error:

mkdir “Old Reports”
ls -1
“Old
Reports”

There are now two folders, and each name has a curly quote in it.

Curly quotes in a CSV file

RFC 4180 defines the quote of a CSV field as DQUOTE, the character %x22, and the quotes are what let a field hold a comma: "Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes." A curly quote protects nothing. In people.csv, the first name was typed with smart quotes on and the second with straight quotes:

name,city
“Smith, John”,Boston
"Jones, Mary",Denver

This command has Python's csv module read the file, and it prints the number of fields in each row, then the fields:

python3 -c 'import csv; [print(len(r), r) for r in csv.reader(open("people.csv", encoding="utf-8"))]'
2 ['name', 'city']
3 ['“Smith', ' John”', 'Boston']
2 ['Jones, Mary', 'Denver']

The curly-quoted name was cut at its comma, so that row has three fields under a header of two, and the curly quotes became part of the data.

How to turn off smart quotes on a Mac

macOS has one setting for the whole system, and TextEdit keeps options of its own. The paths below are quoted from Apple's documentation as it read on November 16, 2026, on the pages written for macOS 27 Golden Gate.

Turn off smart quotes for the whole Mac

Apple's macOS User Guide reaches the setting in three steps. The steps are written for turning it on:

  1. "On your Mac, choose Apple menu > System Settings, then click Keyboard in the sidebar."
  2. "Go to Text Input, then click Edit."
  3. "Turn on “Use smart quotes and dashes.”"

To turn smart quotes off, follow the same steps and turn that setting off. Apple describes its effect as "Automatically convert straight quotation marks to typographical (“curly”) ones, and double hyphens to em dashes," so the one switch covers the quotes and the dashes together. The same guide adds that smart quotes and dashes are not available in all apps. Apple's pages for macOS Tahoe 26 and macOS Sequoia 15 give the same three steps. Its page for macOS Sonoma 14 words the second step as "Go to Text Input on the right, then click Edit."

Turn off smart quotes in TextEdit

TextEdit is included with macOS, and it has its own options for new documents. Apple's TextEdit User Guide gives the path: "choose TextEdit > Settings, then click New Document or Open and Save." The guide's table of New Document options describes three options that matter here:

  • "Smart quotes: Automatically substitute curly quotation marks for straight quotation marks."
  • "Smart quotes and dashes in rich text documents only: Select to automatically substitute straight quotes for curly quotes and double hyphens for em dashes in rich text documents only."
  • Smart dashes, which substitutes an em dash for double hyphens in new documents.

Deselect Smart quotes to stop the substitution. Apple introduces these as settings "for all new TextEdit documents," so they apply to the documents you create afterwards. The pane also has a Restore All Defaults button, which Apple describes as a way to make TextEdit's options "match Keyboard settings."

For code, TextEdit has a plain text format, and Apple's page on HTML documents uses it: "choose File > New, then choose Format > Make Plain Text." While Smart quotes and dashes in rich text documents only is selected, the substitution is limited to rich text documents, by the description quoted above. The same page notes that when TextEdit shows an HTML file as code, "Code-editing mode uses straight quotes and hyphens."

What Apple documents for a document that is already open

Both guides name one more place, Edit > Substitutions > Show Substitutions. The TextEdit guide gives it for a different purpose: "To change the smart quote style in a document, choose Edit > Substitutions > Show Substitutions." The macOS guide gives it for adding smart quotes to text that already exists, where you "make sure the Smart Dashes and Smart Quotes checkboxes are selected, then click Replace in Selection." Neither page presents that window as the way to turn smart quotes off, and neither gives a command that turns curly quotes back into straight ones.

Turning the setting off changes only what happens as you type from then on. The curly quotes that are already in your files stay there, and converting them is the next section.

How do I convert smart quotes to straight quotes in a file?

perl is already installed on a Mac, and one command does the conversion. The example file, notes.txt, is saved as UTF-8. It has seven curly quotes, and it has characters that must stay as they are: primes in a measurement, guillemets, backticks and the ellipsis character.

She said “ship it” and it’s ‘done’.
echo “backup finished”
The shelf is 5′ 10″ wide, see «notes» and `run`…

Find the lines that have curly quotes

List them first, so that you know what will change:

perl -CSD -ne 'print "$.: $_" if /[\x{2018}-\x{201F}]/' notes.txt
1: She said “ship it” and it’s ‘done’.
2: echo “backup finished”

The range in brackets covers the eight curly quote characters from U+2018 to U+201F: the left and right forms in the table above, and the low and reversed forms of each. Line 3 is not listed, because primes and guillemets are outside that range.

Convert curly quotes with one perl command

perl -CSD -pe 's/[\x{2018}-\x{201B}]/\x27/g; s/[\x{201C}-\x{201F}]/"/g' notes.txt > notes-straight.txt

The new file, notes-straight.txt, holds:

She said "ship it" and it's 'done'.
echo "backup finished"
The shelf is 5′ 10″ wide, see «notes» and `run`…

All seven curly quotes are straight, and the primes, the guillemets, the backticks and the ellipsis character are exactly as they were. The first substitution turns the four curly single quotes into the apostrophe, written as \x27 because the program itself sits inside single quotes for the shell. The second turns the four curly double quotes into the straight double quote. -CSD tells perl that its input and its output are UTF-8: in the manual page perlrun, S stands for the three standard streams, and D sets UTF-8 as "the default PerlIO layer" for the files that perl opens. -p runs the program on every line and prints the result.

To change the file itself, add -i with a suffix. perl then edits the file in place and keeps the original beside it under that suffix, here as notes.txt.bak:

perl -CSD -pi.bak -e 's/[\x{2018}-\x{201B}]/\x27/g; s/[\x{201C}-\x{201F}]/"/g' notes.txt

Do the same with sed

sed is also already installed, and four expressions do the same job. The curly characters are part of the command, so copy the line and do not retype it:

sed -e "s/‘/'/g" -e "s/’/'/g" -e 's/“/"/g' -e 's/”/"/g' notes.txt > notes-straight.txt

On notes.txt it writes the same file as the perl command. Keep the four expressions separate. Shortened to bracket expressions such as [‘’], the command depends on the locale of the Terminal session, and in a test with the locale set to C it rewrote single bytes and damaged the primes and the ellipsis character.

Convert long dashes and the ellipsis character too

The commands above change quotes and nothing else. Text that was typed with smart dashes on can also hold an em dash where the writer typed two hyphens. One more command writes two hyphens for an em dash, one hyphen for an en dash and three periods for the ellipsis character:

perl -CSD -pe 's/\x{2014}/--/g; s/\x{2013}/-/g; s/\x{2026}/.../g' dashes.txt > dashes-plain.txt

A test line that held an en dash between two numbers, an em dash and the ellipsis character came out as:

Pages 10-20 -- draft...

When the perl command changes nothing

The command reads the file as UTF-8. A file saved as Windows-1252 stores each curly quote as a single byte, the command passes over those bytes, and the output is identical to the input with no message. The file command tells the two apart: file notes.txt describes that file as Unicode text, UTF-8 text, and it described a Windows-1252 test file as Non-ISO extended-ASCII text. Convert such a file to UTF-8 with iconv, which is already installed, then run the perl command on the result:

iconv -f WINDOWS-1252 -t UTF-8 old-export.txt > old-export-utf8.txt

Quotes that show as “ and ’ are a different problem. That text is UTF-8 that was read in the wrong encoding, and fix garbled text and the wrong encoding covers it. Pasted text often carries more than curly quotes, and how to find and remove invisible characters covers the non-breaking spaces and zero-width characters that arrive with them.

How do I replace curly quotes with find and replace?

Any editor with find and replace can do the conversion one character at a time. Copy a curly quote from the text, paste it into the Find field, type the straight quote into the Replace field, and replace all. Four passes cover the four common characters: the left and right double quotes, then the left and right single quotes. In TextEdit, Apple's guide gives the steps: "choose Edit > Find > Find, then enter text in the search field," then "Select the Replace checkbox next to the Done button, enter the new text in the Replace search field," and "To replace all instances of the found text with the new text, click All."

Two cautions apply in any editor. First, look at the Replace field before you replace, because an app that curls quotes as you type may curl the one you typed there. Second, the right single quote is also the apostrophe in a word such as it’s, so that pass changes every curly apostrophe in the document, which is what code needs and may not be what an essay needs.

An editor with regular expressions needs two passes, because a character class matches any one of the characters between its brackets. Find [“”] and replace with ", then find [‘’] and replace with '. The cheat sheet for find and replace with regular expressions explains character classes and has more recipes.

Find and replace suits one document that is open in front of you. For a folder of files, or for a job that repeats, the perl command is the better tool.

How do I straighten quotes in Caxton?

Caxton has a command for this one conversion. It scans the text, shows what it will change before it changes anything, and works from a short, fixed list of characters. Caxton's text view also has no smart quote substitution of its own, so the quote you type is the quote that goes into the file.

1. Open the file and decide how much to convert

Drag the file onto Caxton, or choose File ▸ Open… and pick it. Opening and viewing are Caxton Free at any file size. With nothing selected, the command works on the whole document. With a selection, it works on the selection only, which is how you straighten the quotes in a block of code and leave the curly quotes in the prose around it. While a line filter is on, it works on the lines the filter shows.

2. Choose Text ▸ Clean Up ▸ Straighten Quotes

Caxton scans the text first. When it finds no curly quotes, no sheet opens, and a banner reports that there are none to straighten. In a CSV that is on screen as a table, the command is unavailable, and step 5 covers that case.

3. Read the preview before anything changes

A sheet attached to the window names the command and its scope in its heading, which reads Straighten Quotes in the whole document? when nothing is selected. The sheet gives the number of changes, one line for each kind of quote it found, a line on whether ⌘Z will reverse the change, and up to five samples that show a short piece of a line before and after. For notes.txt the sheet lists 7 changes: 3 curly single quotes will become apostrophes, and 4 curly double quotes will become straight double quotes. Nothing in the document has changed at this point. Cancel closes the sheet, and the button named Straighten Quotes applies the change.

4. Apply, undo and save

The conversion lands as one undo step, so ⌘Z brings every curly quote back, and a banner confirms how many quotes were straightened. No line ending is changed. The file on disk changes when you save with ⌘S.

Straighten Quotes is an edit to the text, so its tier follows the size of the file. In a file of up to 10 MB, both the preview and the change are Caxton Free. In a larger file the command needs Caxton Pro, which every download includes as a 7-day free trial of Caxton Pro with no credit card required. On Caxton Free, in a file over the limit, no preview opens: a banner gives the reason and has a License… button. The command converts up to 256 MB in one step. In a larger document, select a part of at most that size and run the command again.

A file in another encoding needs no conversion first. Caxton holds a file that it opened in another encoding, such as Windows-1252, as UTF-8 while you work, so the command finds its curly quotes, and Save writes the file back in its own encoding. If the text has bytes that are not valid UTF-8, the command does not run, and a banner points to File ▸ Reopen with Encoding.

5. In a CSV, convert the cells or convert the text

A CSV opens as a table, and there are two ways to straighten its quotes. They do different things.

  • CSV ▸ Transform Cells… has a Cleanup family with its own Straighten Quotes. It changes the same characters, cell by cell, in the scope you choose, such as one column. Each changed cell is written back as correct CSV: a value that now holds a straight double quote is wrapped in quotes, and the quote inside it is doubled. Use it for curly quotes that are part of the values. The sheet and its preview open on Caxton Free, and applying is Caxton Pro at any file size. Transform a CSV column walks through the sheet.
  • View ▸ CSV Grid View switches the document between the table and its text. In the text, Text ▸ Clean Up ▸ Straighten Quotes is available, with the tier described in step 4. It replaces characters and does nothing else, so a curly double quote becomes a real CSV quote. Use it when the curly quotes were meant to be the quotes around fields. In the people.csv example above, the line then reads "Smith, John",Boston, which is one quoted name and one city.

The Characters family of Transform Cells has one more transform, Normalize Quotes and Dashes. It is broader than Straighten Quotes: it also turns primes and the acute accent into straight quotes, and it turns en and em dashes into hyphens. Its tier is the same as for every transform in that sheet.

What does Straighten Quotes change, and what does it leave alone?

The command changes eight characters, and the list is the same in the Text menu and in Transform Cells.

The characterIts name and code pointWhat Straighten Quotes writes
‘Left single quotation mark, U+2018.The apostrophe, U+0027.
’Right single quotation mark, U+2019.The apostrophe, U+0027.
‚Single low-9 quotation mark, U+201A.The apostrophe, U+0027.
‛Single high-reversed-9 quotation mark, U+201B.The apostrophe, U+0027.
“Left double quotation mark, U+201C.The straight double quote, U+0022.
”Right double quotation mark, U+201D.The straight double quote, U+0022.
„Double low-9 quotation mark, U+201E.The straight double quote, U+0022.
‟Double high-reversed-9 quotation mark, U+201F.The straight double quote, U+0022.

Every other character stays as it is and is not counted in the preview. That includes the characters that look like quotes and are something else:

  • The primes ′ and ″, U+2032 and U+2033, which the Unicode chart describes as "minutes, feet" and "seconds, inches."
  • The guillemets «, », ‹ and ›.
  • The backtick ` and the acute accent ´.
  • The fullwidth quotes " and ', and the letter apostrophe U+02BC.
  • The en dash, the em dash and the ellipsis character. The command is about quotes only.
  • Quotes that are already straight, tabs and line endings.

The perl command in this guide was written to match: it changes the same eight code points and no others.

Which way of straightening quotes fits which job?

The jobFree toolsIn Caxton
You want new text to keep its straight quotes.Turn off the setting named Use smart quotes and dashes in Keyboard settings, and deselect Smart quotes in TextEdit's settings.Caxton's text view has no smart quote substitution, so there is nothing to turn off.
One file has curly quotes and needs straight ones.The perl command converts it, and -i.bak keeps the original beside it.Text ▸ Clean Up ▸ Straighten Quotes converts it after a preview.
Only the code inside a document should change.Apple's guide for TextEdit mentions "Replace All In Selection" among the options of the All button.Select the code first, and the command works on the selection only.
A folder of files needs the change, or the same job comes back every week.A script around the perl command is the better tool here.Caxton converts the document that is open in front of you.
The curly quotes are inside the values of a CSV.The perl command straightens them and adds no CSV quoting, so a value that gains a straight double quote can break its row.CSV ▸ Transform Cells… straightens them cell by cell and adds the quoting that CSV requires.
The file is saved as Windows-1252.Convert it to UTF-8 with iconv first, then run the perl command.Caxton holds the file as UTF-8 while you work and saves it back in its own encoding.

Open the file, choose Text ▸ Clean Up ▸ Straighten Quotes, and read the count and the samples in the preview before anything changes.

Download Caxton for Free

7-day free trial of Caxton Pro, every feature, no credit card required. After it, Caxton Free keeps opening, searching and filtering at any size, and you can edit and save files up to 10 MB as text.

Frequently asked questions

How do I turn off smart quotes on a Mac?

Choose Apple menu, then System Settings, and click Keyboard in the sidebar. Go to Text Input, click Edit, and turn off the setting named Use smart quotes and dashes. Those are the steps in Apple's guide for macOS 27 Golden Gate, and its pages for macOS Tahoe 26 and macOS Sequoia 15 give the same ones. TextEdit keeps its own options: choose TextEdit, then Settings, click New Document, and deselect Smart quotes. Turning the setting off stops new curly quotes from appearing. The ones that are already in a file stay there until you convert them.

Why did my code stop working after I pasted it?

The text you pasted most likely carries curly quotes, which an app substituted for the straight ones while the text was being written. Python and the shell in Terminal treat only the straight single quote and the straight double quote as quotes, and JSON accepts only the straight double quote, so a curly one is read as an ordinary character or as an error. Python reports an invalid character, a JSON parser reports that it expected a property name in double quotes, and the shell splits a quoted phrase at its spaces. Convert the quotes with the perl command in this guide or with find and replace, and write code in a plain text editor from then on. If the quotes are already straight and the code still fails, look for characters you cannot see, such as a non-breaking space.

How do I type a straight quote when smart quotes are on?

Apple's documentation gives no keystroke for typing one straight quote while the setting is on. The route it documents is to turn the substitution off. For the whole Mac, that is the setting named Use smart quotes and dashes in System Settings, under Keyboard and then Text Input. In TextEdit, the options are under TextEdit, then Settings, in the New Document pane. While the option there named Smart quotes and dashes in rich text documents only is selected, the substitution is limited to rich text documents, and Format, then Make Plain Text, makes a document plain text. Apple's guide also notes that when TextEdit shows an HTML file as code, that mode uses straight quotes and hyphens.

Does this also fix long dashes?

Turning the setting off does, for new text: Apple's one switch covers smart quotes and dashes together, so double hyphens are no longer turned into em dashes. Converting is separate. The perl command for quotes leaves dashes alone, and so does Caxton's Straighten Quotes, which changes the curly single and double quotes and does not change the en dash, the em dash or the ellipsis character. The free route is one more perl command, shown in this guide, which writes two hyphens for an em dash, one hyphen for an en dash and three periods for the ellipsis character. Find and replace in any editor does the same, one character at a time. For the cells of a CSV, Caxton's Transform Cells has a separate transform named Normalize Quotes and Dashes, which turns en and em dashes into hyphens.

Sources