Smart Quotes Are Ruining Your Code Snippets: How to Keep Quotes Straight
Quick answer
Smart quotes — the curly ‘’ and “” marks your Mac, iPhone, and word processor substitute for the straight ' and " on your keyboard — aren't a stylistic variant. They're a different character entirely, and a parser, shell, or string literal that expects the straight one will choke on the curly one. The fix is three separate settings, not one: macOS, iOS, and Word or Google Docs each run their own auto-correct layer, and switching off one doesn't touch the others. Below: where each toggle lives, what actually breaks when it's left on, and why code has always been the one place typography tools already knew to leave alone.
Step-by-step
Turn it off on Mac
Open the Apple menu, then System Settings, then Keyboard, then Text Input, then Edit, and turn off "Use smart quotes and dashes". That's the system-wide switch. It governs any app that routes typing through the OS text-substitution layer, from Notes to Mail to a plain text field in a browser.
One catch: individual apps can override it locally. Look for Edit > Substitutions inside a specific app — if Smart Quotes is checked there, that app keeps converting even with the system toggle off. This is also why the fastest real fix for anyone who regularly pastes commands, config values, or config files and dotfiles is to do that editing somewhere that never applies OS-level substitution at all. The setting stops being something you have to remember.
Turn it off on iPhone and iPad
Go to Settings, then General, then Keyboard, and turn off "Smart Punctuation." This is the iOS equivalent of the Mac setting, but it's a completely separate toggle. Flipping it off on your iPhone has no effect on your Mac, and vice versa. It also only changes text typed after you make the change — anything already on the screen keeps its existing quote characters.
Turn it off in Word and Google Docs
Word runs its own AutoCorrect rule, independent of whatever the operating system is set to. Go to File, then Options, then Proofing, then AutoCorrect Options, then the AutoFormat As You Type tab, and uncheck "Straight quotes" with "smart quotes." The same checkbox shows up again under the plain AutoFormat tab — uncheck it there too if you're cleaning up a document that's already had its quotes converted.
Google Docs keeps the same idea in a shorter path: Tools, then Preferences, then uncheck "Use smart quotes."
Common problems and fixes
A curly quote breaks a shell command or a JSON/YAML file
Straight quotes in code aren't a style choice. They're syntax. As Practical Typography puts it, "straight quotes and backticks in software code should never be converted to curly quotes. Those marks are, of course, part of the code syntax and must be reproduced literally." The same logic covers file paths, URLs, and shell arguments. If a command that looks correct fails anyway, retype the quote character directly inside the editor rather than pasting it in from Notes, Mail, or a Word doc — that's usually where the substitution happened.
An HTML attribute or JSON value won't parse
A curly-quoted attribute value doesn't close the string the way a browser or parser expects, so the tag or value silently breaks. This isn't a new problem web tooling has to guess its way around. John Gruber's SmartyPants, the tool behind Markdown's optional typographic-punctuation pass, has explicitly excluded `<pre>`, `<code>`, `<kbd>`, `<script>`, and `<math>` from quote conversion since the beginning, because those tags "are used to display text where smart quotes and other 'smart punctuation' would not be appropriate, such as source code or example markup." Code has always been the carve-out, not an edge case a tool forgot to handle. The same instinct applies to escaping special characters in Markdown more broadly — certain characters need to survive exactly as typed.
Quotes were already converted before you noticed
None of the toggles above are retroactive. If a document, note, or snippet already has curly quotes baked in, find-and-replace or retype the affected section — the setting change only stops it from happening again. It's the same family of problem as invisible line-ending mismatches: a silent, editor-driven transformation that corrupts a plain-text file in a way you can't see until something downstream fails to parse it.
Frequently Asked Questions
Why do smart quotes break code but not regular writing?
Smart (curly) quotes are different Unicode characters than the straight ASCII quotes a parser, shell, or string literal expects. Prose doesn't care which one it sees, but code, JSON, YAML, and HTML attributes treat quote characters as syntax, so the wrong character produces a parse error or a value that silently doesn't match what you typed.
If I turn off smart quotes on my Mac, does that also fix my iPhone?
No. macOS and iOS have separate, independent toggles — System Settings > Keyboard > Text Input > Edit on Mac, and Settings > General > Keyboard > Smart Punctuation on iOS. Turning one off doesn't touch the other, so anyone who drafts on iPad and finishes on Mac needs to flip both.
Will turning off smart quotes fix text I already typed?
No. The toggle only changes how new text is typed going forward. Quotes already converted in an existing document, note, or file stay curly until you manually find-and-replace them or retype that section.
Does Word's smart-quotes setting follow the macOS or iOS setting?
No. Word and Google Docs run their own AutoCorrect rule independent of the operating system. Turning off the OS-level smart-quotes toggle doesn't stop Word from converting quotes inside a Word document — that requires unchecking the AutoFormat As You Type option inside Word itself.
Doing this with Carets
The real fix for anyone who moves between writing and code all day isn't remembering to flip three separate settings. It's editing code somewhere that never applies OS-level text substitution in the first place. Carets is a native notes and code editor for iPhone, iPad, and Mac that handles Markdown, plain text, and code with syntax highlighting in one app, so a quote typed inside a code block stays exactly the character you typed.
Snippets, config values, and commands stay organized in files, projects, and tags. And because Carets is native and fast rather than a web wrapper, there's no browser text field or document-editor substitution layer sitting between your keystroke and the file on disk. The text you store is the text you get back — on iPhone, iPad, and Mac alike.
Carets is available on the App Store for iPhone, iPad, and Mac.