How to Format Inline Quotations

Format inline quotations in US English: which quote marks to use, where punctuation goes, how to nest quotes, and how to convert straight quotes to smart quotes and check the result.

An inline quotation is quoted material that runs inside your own sentence instead of being set off as a separate block. Formatting one correctly involves two layers. The first is the style rules: which marks to use, where surrounding punctuation goes, and how to handle a quote within a quote. The second is the characters themselves: straight quotes typed from a keyboard versus curly, typographic quotes, often called smart quotes. This guide covers both and includes a conversion workflow you can check afterward.

What quote formatting does to your text

A smart-quote conversion takes text containing straight quote characters and replaces each one with the correct opening or closing typographic mark. The result should differ from the input only in those characters. Words, spacing, line breaks and other punctuation should stay exactly as they were. The style rules in the next section then decide where commas, periods and other marks sit relative to the quotes.

Name | Character | Unicode code point | Typical use
Straight double quote | " | U+0022 | Code, data files, plain-text fallback
Left double quotation mark | “ | U+201C | Opens an inline quotation in US style
Right double quotation mark | ” | U+201D | Closes an inline quotation
Left single quotation mark | ‘ | U+2018 | Opens a quotation nested inside another
Right single quotation mark | ’ | U+2019 | Closes a nested quotation; also the typographic apostrophe
Straight single quote | ' | U+0027 | Code, data files, plain-text fallback

Some content must not be converted. Source code, JSON, CSV, HTML attribute values and regular expressions depend on straight quotes, and curly ones can break them. Measurements are a separate case: feet and inches are properly written with the prime (′, U+2032) and double prime (″, U+2033), not with quotation marks of either kind.

US style rules for inline quotations

  • Put the quoted words in double quotation marks. Example: She called the draft “nearly finished.”
  • Use single marks for a quotation inside a quotation. Example: He said, “The sign read ‘Closed for inventory,’ so we left.”
  • Place periods and commas inside the closing mark, even when they are not part of the original wording.
  • Place colons and semicolons outside the closing mark.
  • Place question marks and exclamation points inside only when they belong to the quoted material. Examples: She asked, “Is it ready?” versus Did he really call it “ready”?
  • When a signal phrase such as she said introduces a full-sentence quotation, put a comma after the phrase and capitalize the first quoted word. When the quotation fits into your own grammar, skip the comma and keep the original lowercase. Example: The report calls the delay “unavoidable.”
  • Mark omitted words with an ellipsis (…) and your own insertions or changes with square brackets.

Longer quotations are usually set as block quotations without quotation marks. The length threshold depends on the style guide. MLA uses more than four lines of prose, and APA uses 40 words or more. Follow whichever guide your publication or course requires.

Converting straight quotes to smart quotes

Before you start, you need three things: the text saved as UTF-8 (plain ASCII also works because it is a subset of UTF-8), a copy of the original, and a list of any spans that must keep straight quotes. The example below uses Perl because it refers to characters by Unicode code point, which avoids shell-quoting problems. It is an illustrative sketch and has not been tested on your files or on any particular Perl version.

  • 1. Copy the original so the conversion never overwrites it.
  • 2. Confirm the encoding. The file -i command should report charset=utf-8 or charset=us-ascii.
  • 3. Run the conversion and write the output to a new file.
  • 4. Run the checks in the next section.
  • 5. Fix the reported exceptions by hand, and restore straight quotes in any code or data spans.
cp article.txt article.orig.txt
file -i article.orig.txt
perl -CSD -pe '
  s/(^|[\s(\[{\x{2014}])\x{22}/$1\x{201C}/g;
  s/\x{22}/\x{201D}/g;
  s/(^|[\s(\[{\x{2014}])\x{27}/$1\x{2018}/g;
  s/\x{27}/\x{2019}/g;
' article.orig.txt > article.smart.txt

How the rules work: a straight quote at the start of a line, or one that follows whitespace, an opening bracket or an em dash, becomes an opening mark. Every remaining straight quote becomes a closing mark. Because the same logic applies to single quotes, apostrophes inside words, as in don't, become U+2019, which is correct. The -CSD option tells Perl to read and write UTF-8. Without it, existing curly quotes or accented letters can be corrupted. The script processes one line at a time and leaves LF or CRLF line endings unchanged. A line that begins with a closing mark, which can happen in hard-wrapped text, will incorrectly receive an opening mark. Because the script converts every quote in the file, it also converts quotes inside code samples, so handle those spans separately.

Before and after example

Example input:

She said, "The sign read 'Closed for inventory,' so we left."
Rock 'n' roll peaked in the '50s, and the board is 6' 2" long.

Applying the rules above to this example gives the following output. This was worked out from the rules, not captured from a test run:

She said, “The sign read ‘Closed for inventory,’ so we left.”
Rock ‘n’ roll peaked in the ‘50s, and the board is 6’ 2” long.

The first line is correct, including the nested single quotes. The second line shows three cases that rule-based conversion gets wrong. In rock 'n' roll, both marks stand for omitted letters, so both should be apostrophes (’). In '50s, the leading mark is also an apostrophe, not an opening quote. The measurement needs primes instead of quotation marks. The corrected line is:

Rock ’n’ roll peaked in the ’50s, and the board is 6′ 2″ long.

Checking the result

Run these three checks against the converted file. The first maps every curly quote back to a straight one and compares the result with the original. No differences means only quote characters changed. If the original already contained curly quotes, those lines will also appear in the diff, which is expected. The second counts opening and closing double marks, which should normally be equal. Single marks are not counted because apostrophes make that comparison meaningless. The third prints lines where an opening single mark comes before a digit or a closing mark comes after one. These are the usual signs of abbreviated years and measurements. Review each reported line by hand, because a legitimate quotation such as “10” will also be flagged.

perl -CSD -pe 'tr/\x{201C}\x{201D}\x{2018}\x{2019}/\x{22}\x{22}\x{27}\x{27}/' article.smart.txt | diff article.orig.txt - && echo "only quote marks changed"
perl -CSD -ne '$o += () = /\x{201C}/g; $c += () = /\x{201D}/g; END { print "open=$o close=$c\n" }' article.smart.txt
perl -CSD -ne 'print "$.: $_" if /\x{2018}\d|\d[\x{2019}\x{201D}]/' article.smart.txt

If any check shows unwanted changes, delete article.smart.txt and start again from article.orig.txt, which the workflow never modifies. Finally, read the nested quotations yourself. The script cannot tell whether a single mark opens a nested quote or stands in for missing letters.

Word processors and text editors

Many word processors include a smart-quotes setting that converts quotes as you type. Text pasted in from elsewhere may not be converted, and option names and behavior vary by application and version, so check your application's documentation instead of assuming. When you are writing code or data in the same application, turn the setting off so straight quotes stay straight.

Gaps and limits

No tool-specific documentation was provided for this guide. The commands follow standard Perl, grep-style and diff behavior but have not been verified against a particular system, and the example output was derived from the rules rather than produced by running them. The guide covers US English conventions only. Other languages use different marks, such as « » or „ “, and need different rules.