string.unquote() belongs to the built-in sass:string module. It returns a string without Sass quotes so the compiled CSS can emit bare values, filters, or selectors. This page covers the official caution, vs string.quote, and five compiled examples.
01
Concept
Remove quotes
02
Module
@use "sass:string"
03
Returns
Unquoted string
04
Caution
May be invalid CSS
05
Pair
string.quote
06
Practice
5 examples
Concept
What Is string.unquote()?
Official docs: returns $string as an unquoted string. This can produce strings that aren’t valid CSS, so use with caution.
Strips the Sass quote markers so output CSS has no surrounding ".
Useful for injecting full CSS fragments you already trust.
Dangerous with spaces or selector text if you emit them as normal property values.
Opposite helper: string.quote().
💡
Beginner tip
Think of peeling a label off a jar. "Helvetica" becomes bare Helvetica. Peeling ".widget:hover" gives .widget:hover—handy for interpolation, risky as a plain property value.
Foundation
📝 Syntax
styles.scss
@use "sass:string";
// Recommended
string.unquote($string)
// Legacy global name
unquote($string)
Parameters
Parameter
Type
Required
Description
$string
String
Yes
The string to return without Sass quotes.
Return value
Type
Result
String (unquoted)
$string without surrounding Sass quotes
Modules
📦 Loading sass:string
styles.scss
// Recommended — namespaced (Dart Sass 1.23+)
@use "sass:string";
$name: string.unquote("Helvetica"); // Helvetica
// Optional — bring members into scope
@use "sass:string" as *;
$name: unquote("Helvetica");
// Legacy global
$name: unquote("Helvetica");
Details
🎨 Official Patterns
Call
Result
unquote("Helvetica")
Helvetica
unquote(".widget:hover")
.widget:hover
These are the official Sass documentation samples. The second result is selector-shaped text—safe when interpolated into a selector, not as a normal property value.
Compare
⚖️ quote vs unquote
Helper
Quote state
Typical use
string.quote
Quoted
font-family, content, spaced names
string.unquote
Unquoted
Inject CSS fragments, selector strings
⚠️
Official caution
Unquoting can emit CSS that browsers cannot parse. Prefer string.quote when the value needs quotes. Prefer interpolation (#{$sel} when you intentionally build a selector.
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Quote state is resolved at compile time.
Implementation
unquote
Dart Sass
Yes — prefer string.unquote (module since 1.23.0)
LibSass
Legacy unquote may exist; no @use "sass:string"
Ruby Sass
Legacy unquote may exist; no @use "sass:string"
Prefer current Dart Sass so the module API matches the official docs.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import string
@use "sass:string";
Remove quotes
string.unquote("Helvetica")
Inspect quote state
meta.inspect(string.unquote($s))
Inject a CSS value
filter: string.unquote("blur(4px)");
Build a selector
#{$sel} { ... } after unquoting
Opposite helper
string.quote($string)
Hands-On
Examples Gallery
Each example uses string.unquote at compile time (Dart Sass 1.23+). Open View Compiled CSS for verified output.
📚 Getting Started
Official docs samples, then a font-family without quotes.
Interpolation turns the unquoted string into a real selector. This matches the spirit of the official .widget:hover sample.
Applications
🚀 Real-World Use Cases
CSS value injection — emit filter, transform, or similar fragments from strings.
Dynamic selectors — unquote then interpolate into a rule head.
API boundaries — accept quoted config strings and emit bare CSS tokens.
Debugging quote state — pair with meta.inspect to see before/after.
Opposite of quote — normalize values that must not keep CSS quotes.
🧠 How Compilation Works
1
Pass a string
Call string.unquote($string).
Source
2
Sass drops quote markers
The value becomes an unquoted Sass string.
Compile
3
Emit or interpolate
Use as a property value or inside #{$sel}.
Emit
4
✓
CSS ships
Browsers only see finished text like Helvetica or blur(4px).
Watch Out
⚠️ Common Pitfalls
Invalid CSS — official docs warn unquote can emit unparsable values.
Spaced font names — keep quotes with string.quote instead.
Selector as a property value — interpolate selectors; do not dump them into props.
Confusing with CSS — browsers never see unquote().
Forgetting the opposite — use string.quote when quotes are required.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:string" and string.unquote()
Unquote only when bare CSS output is intentional
Interpolate selector strings with #{$sel}
Inspect with meta.inspect while learning
Prefer Dart Sass 1.23+
❌ Don’t
Unquote spaced names meant for font-family
Ignore the official invalid-CSS warning
Use unquote when string.quote is what you need
Expect browsers to evaluate the call
Rely on LibSass for the module API
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about string.unquote()
Remove Sass quotes so CSS can emit bare values—carefully.
5
Core concepts
📝01
API
unquote($string)
Call
📦02
Module
sass:string
@use
🔗03
Result
unquoted string
Output
📚04
Caution
may be invalid CSS
Rule
✓05
Pair
string.quote
Pattern
❓ Frequently Asked Questions
string.unquote($string) returns $string as an unquoted Sass string. Example: string.unquote("Helvetica") becomes Helvetica.
Yes. Official docs warn that unquote can produce strings that are not valid CSS. Use it carefully, especially with spaces or selector-like text.
quote adds or keeps CSS quotes around a value. unquote removes them so the value is emitted without surrounding quotes.
Common cases include injecting a full CSS value string (like filter: blur(4px)), interpolating a selector string into a rule, or normalizing a value that must appear unquoted in the output.
Yes. unquote($string) is the legacy global name. Prefer string.unquote after @use "sass:string".
Dart Sass 1.23+. LibSass and Ruby Sass do not load sass:string with @use; they may still offer the legacy global name.
Did you know?
Official Sass docs unquote ".widget:hover" to .widget:hover—and immediately warn that unquote can create strings that are not valid CSS.
string.unquote() returns an unquoted Sass string so compiled CSS can emit bare values, filters, or interpolated selectors. Use it carefully—official docs warn it can produce invalid CSS. Prefer string.quote when quotes are required.