Strings are sequences of Unicode characters. Sass has two kinds with the same internal type but different CSS output: quoted ("Helvetica Neue" and unquoted identifiers like bold.
Prefer quoted by default.
Use unquoted only when CSS needs an identifier. Color names, null, true/false, and and/or/not are not unquoted strings.
Interpolation strips quotes.
Injecting a quoted string with #{ } removes the quotes—handy for selectors. See interpolation.
Indexes start at 1.
1 is the first character; -1 is the last. Missing searches return null.
Syntax
Syntax
SCSS
@use "sass:string";
"Helvetica Neue"; // quoted
bold; // unquoted identifier
"Roboto #{$variant}"; // interpolation inside quotes
string.quote(bold); // "bold"
string.unquote(".a:hover"); // .a:hover
string.index($s, "Neue"); // 1-based index, or null
string.slice($s, -4); // from near the end
Pattern: pick quoted or unquoted → convert with string.quote / string.unquote → search/slice with 1-based indexes.
One line: quote text by default, unquote when CSS needs an identifier, and remember interpolation drops quotes.
Practice
Compile Notes
Practical checklist:
checklist.txt
1. Prefer "quoted" strings for most text
2. Use unquoted only for CSS identifiers
3. Convert with string.quote / string.unquote
4. Remember #{} removes quotes
5. Use 1-based indexes with string.index / slice
Frequently Asked Questions
Strings are sequences of Unicode characters. Sass has quoted strings (like "Helvetica Neue") and unquoted strings/identifiers (like bold). Internally they are the same type; they render differently in CSS.
Prefer quoted strings unless you are writing a CSS property that needs an unquoted identifier. Color names, null, true/false, and and/or/not are not parsed as unquoted strings.
Use string.quote() to add quotes and string.unquote() to remove them. Load them with @use "sass:string".
No. Index 1 is the first character. Negative indexes count from the end: -1 is the last character.
When a quoted string is injected via #{…}, its quotes are removed. That makes it easy to build selectors from quoted variables.
It returns null, which is falsey—handy inside @if conditions.