Sass string.to-lower-case() Function

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

What You’ll Learn

string.to-lower-case() belongs to the built-in sass:string module. It returns a copy of a string with ASCII letters converted to lower case. This page covers quote state, Sass vs CSS text-transform, and five compiled examples.

01

Concept

Lowercase ASCII

02

Module

@use "sass:string"

03

Returns

New string

04

Quotes

Preserved

05

Vs CSS

text-transform

06

Practice

5 examples

What Is string.to-lower-case()?

Official docs: returns a copy of $string with the ASCII letters converted to lower case.

  • The original string is not mutated—you always get a new value.
  • Quoted strings stay quoted; unquoted strings stay unquoted.
  • Hyphens, digits, and spaces are left alone.
  • Pair with string.to-upper-case when you need the opposite.
💡
Beginner tip

Think of a stamp that only lowercases A–Z. "Bold" becomes "bold", and unquoted SANS-SERIF becomes sans-serif.

📝 Syntax

styles.scss
@use "sass:string";

// Recommended
string.to-lower-case($string)

// Legacy global name
to-lower-case($string)

Parameters

ParameterTypeRequiredDescription
$stringStringYesThe string to copy and lowercase.

Return value

TypeResult
StringA new string with ASCII letters in lower case (quote state preserved)

📦 Loading sass:string

styles.scss
// Recommended — namespaced (Dart Sass 1.23+)
@use "sass:string";
$label: string.to-lower-case("Bold"); // "bold"

// Optional — bring members into scope
@use "sass:string" as *;
$label: to-lower-case("Bold");

// Legacy global
$label: to-lower-case("Bold");

🎨 Official Patterns

CallResult
to-lower-case("Bold")"bold" (quoted)
to-lower-case(SANS-SERIF)sans-serif (unquoted)

These are the official Sass documentation samples. Notice the hyphen stays, and quote state matches the input.

⚖️ Sass vs CSS text-transform

TopicSass string.to-lower-caseCSS text-transform: lowercase
When it runsCompile timeIn the browser
What changesThe string value itselfHow text is displayed
Best forClass names, tokens, fixed CSS valuesVisible page text styling
⚠️
ASCII only in Sass

Official docs convert ASCII letters. For full Unicode casing of visible copy, CSS text-transform is often the better tool.

🛠 Compatibility

This is about Sass compilers, not browsers. Uppercasing happens at compile time.

Implementationto-lower-case
Dart SassYes — prefer string.to-lower-case (module since 1.23.0)
LibSassLegacy to-lower-case may exist; no @use "sass:string"
Ruby SassLegacy to-lower-case 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";
Lowercase a labelstring.to-lower-case("Bold")
Lowercase unquotedstring.to-lower-case(SANS-SERIF)
Build a class token.action-#{string.to-lower-case($name)}
Opposite helperstring.to-upper-case($string)
Display-only lowerUse CSS text-transform: lowercase

Examples Gallery

Each example uses string.to-lower-case at compile time (Dart Sass 1.23+). Open View Compiled CSS for verified output.

📚 Getting Started

Official docs samples, then a font-family token.

Example 1 — Official Lowercase Samples

Quoted and unquoted inputs keep their quote state.

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

.probe {
  --quoted: #{meta.inspect(string.to-lower-case("Bold"))};
  --unquoted: #{meta.inspect(string.to-lower-case(SANS-SERIF))};
}

How It Works

Matches the official docs. meta.inspect shows quotes clearly: "bold" vs bare sans-serif.

Example 2 — Lowercase a Font Name

Compile-time lowercase for a family token (not browser display transform).

styles.scss
@use "sass:string";

.heading {
  font-family: string.to-lower-case("ROBOTO"), sans-serif;
  text-transform: none;
}

How It Works

Sass writes "roboto" into the CSS file. Setting text-transform: none shows this is not a browser visual transform.

📈 Practical Patterns

Modifiers, content labels, and looped class tokens.

Example 3 — Normalize a Modifier Token

Store a lowercase variant of a modifier name.

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

$mod: "PRIMARY";

.btn {
  --mod: #{meta.inspect(string.to-lower-case($mod))};
}

How It Works

Useful when design tokens or debug props should always appear in a fixed case.

Example 4 — Lowercase content Labels

A tiny helper for badge text that must be lowercase in CSS.

styles.scss
@use "sass:string";

@function lower-id($name) {
  @return string.to-lower-case($name);
}

.badge::before {
  content: lower-id("NEW");
}

How It Works

The helper keeps call sites readable. The compiled CSS contains the finished "new" string.

Example 5 — Lowercase Class Tokens In A Loop

Build action classes and matching content values.

styles.scss
@use "sass:string";

$parts: ("SAVE", "EDIT", "DELETE");

@each $part in $parts {
  .action-#{string.to-lower-case($part)} {
    content: string.to-lower-case($part);
  }
}

How It Works

Interpolation drops Sass quotes in the selector, so you get classes like .action-save, while content keeps the quoted string.

🚀 Real-World Use Cases

  • Token normalization — force modifiers or flags into a fixed case.
  • Generated class names — lowercase segments in BEM-style or utility loops.
  • Pseudo-element labels — bake lowercase into content strings.
  • Debug props — print lowercase variants with meta.inspect.
  • Pair with upper-case — normalize both directions in shared helpers.

🧠 How Compilation Works

1

Pass a string

Call string.to-lower-case($string).

Source
2

Sass lowercases ASCII letters

Digits, hyphens, and quote state stay the same.

Compile
3

Use the new string

Assign to CSS properties or interpolate into selectors.

Emit
4

CSS ships

Browsers only see finished text like "bold" or sans-serif.

⚠️ Common Pitfalls

  • Expecting Unicode casing — docs convert ASCII letters; use CSS for display casing of rich text.
  • Confusing with text-transform — Sass changes the value; CSS changes display.
  • Expecting mutation — the original variable stays unchanged.
  • Forgetting quote state — quoted inputs stay quoted in the result.
  • Uppercasing for looks only — prefer CSS when you only want visual lowercase.

💡 Best Practices

✅ Do

  • Use @use "sass:string" and string.to-lower-case()
  • Use it for tokens, class fragments, and fixed CSS strings
  • Pair with string.to-upper-case for normalization
  • Inspect quote state with meta.inspect while learning
  • Prefer Dart Sass 1.23+

❌ Don’t

  • Assume full Unicode case conversion
  • Replace CSS text-transform for visible page copy
  • Expect the original string variable to change
  • Expect browsers to evaluate the call
  • Rely on LibSass for the module API

Key Takeaways

Knowledge Unlocked

Five things to remember about string.to-lower-case()

Copy a string and convert ASCII letters to lower case at compile time.

5
Core concepts
📦 02

Module

sass:string

@use
🔗 03

Result

new lowercase string

Output
📚 04

Scope

ASCII letters

Rule
05

Pair

to-upper-case

Pattern

❓ Frequently Asked Questions

string.to-lower-case($string) returns a copy of $string with ASCII letters converted to lower case. Example: string.to-lower-case("Bold") is "bold".
Yes. Official sample: string.to-lower-case(SANS-SERIF) becomes sans-serif (still unquoted).
Yes. Official docs say ASCII letters are converted. Digits, hyphens, spaces, and most non-ASCII characters stay as they are.
Same idea, different stage. Sass changes the string at compile time. CSS text-transform changes how the browser displays text at runtime.
Yes. to-lower-case($string) is the legacy global name. Prefer string.to-lower-case 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 lowercase both "Bold" and unquoted SANS-SERIF—quote state is preserved while letters change case.

Conclusion

string.to-lower-case() returns a copy of a string with ASCII letters in lower case. Quote state is preserved, and the work happens at compile time. Use CSS text-transform when you only need visual lowercase for page text.

Continue with string.to-upper-case() or the Sass introduction.

Next: uppercase strings

Learn string.to-upper-case() to convert ASCII letters at compile time.

string.to-upper-case() →

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