The Silent Saboteur
You copy a code snippet from a blog post, paste it into your terminal, and get a cryptic error. The code looks correct. You stare at it for ten minutes before noticing: the quote marks are slightly curved. Those are smart quotes (also called curly quotes or typographic quotes), and they break code.
This is one of the most common sources of invisible bugs for developers, especially when copying from:
- Word processors (Microsoft Word, Google Docs)
- CMS editors (WordPress, Medium, Notion)
- PDF documents
- Some email clients
- AI-generated text formatted for reading rather than execution
Straight Quotes vs Smart Quotes
Straight quotes (what code expects):
'– U+0027, ASCII apostrophe / single quote"– U+0022, ASCII double quote
Smart quotes (what word processors insert):
'– U+2018, left single quotation mark'– U+2019, right single quotation mark / apostrophe"– U+201C, left double quotation mark"– U+201D, right double quotation mark
These are entirely different Unicode characters. No programming language, shell, or config format treats them as equivalent to their ASCII counterparts.
What Breaks
Shell commands – bash, zsh, PowerShell all use ASCII quotes to delimit strings. Smart quotes cause a syntax error or are treated as literal characters in the argument.
JSON – JSON requires U+0022 (") for string delimiters and keys. Smart double quotes produce a parse error in every JSON parser.
Python, JavaScript, PHP – string literals must use ASCII quote characters. Smart quotes cause a SyntaxError.
Config files – YAML, TOML, .env files, SSH config – all expect ASCII.
CSS – font names and attribute selectors in quotes must use ASCII.
Where Smart Quotes Come From
Most word processors apply "autocorrect" that replaces straight quotes with curly ones as you type. This makes prose look more typographically correct but makes any code in the document invalid.
When you copy text from these sources and paste into a code editor, the smart quotes come with it. Most code editors do NOT automatically convert them – they display them, but they are invalid characters for code purposes.
How to Find and Fix Them
In a code editor
Most editors can search by regex. The pattern [''""‛‟] matches common smart quote variants. Search your file and replace with the appropriate ASCII character.
With a text cleaning tool
The Typographic Cleaner on this site converts all curly/smart quotes, ellipses (... → ...), em dashes, and other typographic characters back to their ASCII equivalents in one click. Paste your text, clean it, copy back.
In the terminal
sed -i "s/\xe2\x80\x98/'/g; s/\xe2\x80\x99/'/g; s/\xe2\x80\x9c/\"/g; s/\xe2\x80\x9d/\"/g" file.txt
Prevent autocorrect at the source
In Word: File → Options → Proofing → AutoCorrect Options → AutoFormat As You Type → uncheck "Replace straight quotes with smart quotes".
In Google Docs: Tools → Preferences → uncheck "Use smart quotes".
The Ellipsis Problem
The same issue applies to the ellipsis character ... (U+2026), which is a single character that looks like ... (three periods) but is not equivalent in code. If you paste ... into a regex or a config file expecting ..., it will silently fail.
Summary
Smart quotes are typographic improvements designed for reading text, not writing code. They are different Unicode characters from ASCII quotes and will break any code, config, or CLI command that receives them. Always work in a plain text editor (VS Code, Sublime, Vim) rather than a word processor when writing code, and clean pasted text before using it.