Sass string.unquote() Function

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:string · Dart Sass 1.23+

What You’ll Learn

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

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.

📝 Syntax

styles.scss
@use "sass:string";

// Recommended
string.unquote($string)

// Legacy global name
unquote($string)

Parameters

ParameterTypeRequiredDescription
$stringStringYesThe string to return without Sass quotes.

Return value

TypeResult
String (unquoted)$string without surrounding Sass quotes

📦 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");

🎨 Official Patterns

CallResult
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.

⚖️ quote vs unquote

HelperQuote stateTypical use
string.quoteQuotedfont-family, content, spaced names
string.unquoteUnquotedInject 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.

🛠 Compatibility

This is about Sass compilers, not browsers. Quote state is resolved at compile time.

Implementationunquote
Dart SassYes — prefer string.unquote (module since 1.23.0)
LibSassLegacy unquote may exist; no @use "sass:string"
Ruby SassLegacy unquote may exist; no @use "sass:string"

Prefer current Dart Sass so the module API matches the official docs.

⚡ Quick Reference

GoalCode
Import string@use "sass:string";
Remove quotesstring.unquote("Helvetica")
Inspect quote statemeta.inspect(string.unquote($s))
Inject a CSS valuefilter: string.unquote("blur(4px)");
Build a selector#{$sel} { ... } after unquoting
Opposite helperstring.quote($string)

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.

Example 1 — Official Unquote Samples

A simple name and a selector-shaped string.

styles.scss
@use "sass:meta";
@use "sass:string";

.probe {
  --quoted: #{meta.inspect(string.unquote("Helvetica"))};
  --selector: #{meta.inspect(string.unquote(".widget:hover"))};
}

How It Works

Matches the official docs. meta.inspect shows bare identifiers without surrounding quotes.

Example 2 — Unquoted Font Family Token

Emit a single-word family name without CSS quotes.

styles.scss
@use "sass:string";

.heading {
  font-family: string.unquote("Roboto"), sans-serif;
}

How It Works

Single-token names can be unquoted. For names with spaces, keep string.quote so CSS stays valid.

📈 Practical Patterns

Quote-state comparison, CSS value injection, and selector build.

Example 3 — Quoted vs Unquoted Side By Side

See how spaces look after unquote.

styles.scss
@use "sass:meta";
@use "sass:string";

$family: "Segoe UI";

.compare {
  --kept: #{meta.inspect($family)};
  --bare: #{meta.inspect(string.unquote($family))};
}

How It Works

--bare loses the quotes. As a font-family value that would be risky; here it is only shown via meta.inspect for learning.

Example 4 — Inject A Full CSS Value

Pass a complete filter expression as a quoted string, then unquote it.

styles.scss
@use "sass:string";

@mixin inject-filter($value) {
  filter: string.unquote($value);
}

.card {
  @include inject-filter("blur(4px)");
}

How It Works

Without unquote, Sass might keep the whole value as a quoted string. Unquoting lets the CSS function text compile as a real filter value.

Example 5 — Build A Selector From A String

Unquote a selector string, then interpolate it into a rule.

styles.scss
@use "sass:string";

$sel: string.unquote(".btn:focus-visible");

#{$sel} {
  outline: 2px solid currentColor;
}

How It Works

Interpolation turns the unquoted string into a real selector. This matches the spirit of the official .widget:hover sample.

🚀 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).

⚠️ 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.

💡 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

Key Takeaways

Knowledge Unlocked

Five things to remember about string.unquote()

Remove Sass quotes so CSS can emit bare values—carefully.

5
Core concepts
📦 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.

Conclusion

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.

Continue with Sass equality operators or browse string.quote().

Next: Sass Equality Operators

Compare numbers, strings, colors, lists, and maps with == and !=.

Equality operators →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful