Sass meta.inspect() Function

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:meta · debugging

What You’ll Learn

meta.inspect() belongs to the built-in sass:meta module. It turns any Sass value into an unquoted string so you can see what the compiler is holding. This page covers lists, maps, null, strings, why the format is for debugging only, and five compiled examples.

01

Concept

Value → debug string

02

Module

@use "sass:meta"

03

Returns

Unquoted string

04

Purpose

Debugging

05

Caution

Format not stable

06

Practice

5 examples

What Is meta.inspect()?

Official docs: returns a string representation of $value. It works for any Sass value—not only things that can appear in CSS. That makes it perfect for @debug and temporary inspection, and a poor choice for permanent production CSS.

💡
Beginner tip

Think of inspect as a flashlight for your Sass values. Use it to look around, not as a permanent light fixture in your stylesheet.

⚠️
Official heads-up

Intended for debugging. The output format is not guaranteed to stay the same across Sass versions or implementations. Do not depend on the exact string in shipped CSS.

📝 Syntax

styles.scss
@use "sass:meta";

// Recommended
meta.inspect($value)

// Legacy global name
inspect($value)

Parameters

ParameterTypeRequiredDescription
$valueAnyYesAny Sass value: number, color, list, map, string, boolean, null, and more.

Return value

TypeResult
Unquoted stringA human-readable representation of $value (not guaranteed CSS-safe)

📦 Loading sass:meta

styles.scss
// Recommended — namespaced
@use "sass:meta";
@debug meta.inspect((a: 1, b: 2));

// Optional — bring members into scope
@use "sass:meta" as *;
@debug inspect(null);

// Legacy global
@debug inspect("Helvetica");

🔎 @debug vs Emitting CSS

Official samples use @debug meta.inspect(…), which prints to the compiler console and does not appear in CSS. For tutorials and DevTools peeks, you can also interpolate into a custom property temporarily:

styles.scss
@use "sass:meta";

// Console only (best for day-to-day debugging)
@debug meta.inspect(("width": 200px));

// Temporary CSS token (remove before shipping)
:root {
  --peek: #{meta.inspect(("width": 200px))};
}

🛠 Compatibility

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

Implementationinspect
Dart SassYes — prefer meta.inspect
LibSassYes (legacy global / pipelines)
Ruby SassYes (legacy global / pipelines)

Prefer current Dart Sass, and treat the string format as a debug convenience.

⚡ Quick Reference

GoalCode
Import meta@use "sass:meta";
Inspect a valuemeta.inspect($value)
Print to console@debug meta.inspect($value);
Peek in CSS (temporary)--peek: #{meta.inspect($value)};
AvoidDepending on the exact string in production CSS

Examples Gallery

Examples interpolate meta.inspect into custom properties so you can open View Compiled CSS. In real projects, prefer @debug and remove these tokens before shipping.

📚 Getting Started

Official-style samples for lists, maps, null, and strings.

Example 1 — Inspect a List

Space-separated lengths become a readable string.

styles.scss
@use "sass:meta";

// @debug meta.inspect(10px 20px 30px);
:root {
  --list: #{meta.inspect(10px 20px 30px)};
}

How It Works

Official docs describe this as an unquoted string like 10px 20px 30px—handy when a list is hard to visualize mid-compile.

Example 2 — Inspect a Map

Maps are Sass-only; inspect shows their structure as text.

styles.scss
@use "sass:meta";

// @debug meta.inspect(("width": 200px));
:root {
  --map: #{meta.inspect(("width": 200px))};
}

How It Works

You cannot put a Sass map directly into CSS. inspect gives you a string snapshot like ("width": 200px) for debugging.

📈 More Value Types

Null, quoted strings, and a mixed peek panel.

Example 3 — Inspect null

null has no CSS form; inspect still describes it.

styles.scss
@use "sass:meta";

// @debug meta.inspect(null);
:root {
  --null: #{meta.inspect(null)};
}

How It Works

Official docs: inspecting null yields the text null. That is why this helper is for humans debugging, not for finished stylesheet design.

Example 4 — Inspect a Quoted String

Quoted Sass strings keep their quotes visible in the inspect output.

styles.scss
@use "sass:meta";

// @debug meta.inspect("Helvetica");
:root {
  --font: #{meta.inspect("Helvetica")};
}

How It Works

Official docs show inspect revealing that the value is a quoted string ("Helvetica"), which helps when quote style matters for later string helpers.

Example 5 — Mixed Debug Panel

Inspect several types side by side while learning Sass values.

styles.scss
@use "sass:meta";

$tokens: (
  "gap": 1rem,
  "ok": true
);

:root {
  --number: #{meta.inspect(42)};
  --bool: #{meta.inspect(true)};
  --tokens: #{meta.inspect($tokens)};
}

How It Works

Numbers and booleans stringify simply; the map shows keys and values together. Treat this panel as a learning aid, then delete it.

🚀 Real-World Use Cases

  • @debug while coding — print maps/lists that do not fit in CSS.
  • Teaching Sass types — show beginners what a value “looks like” to the compiler.
  • Temporary DevTools peeks — custom properties during local development only.
  • Library diagnostics — help consumers understand unexpected config shapes.
  • Not for design tokens in production — prefer real CSS values and maps APIs.

🧠 How Compilation Works

1

Pass any Sass value

Call meta.inspect($value) with a list, map, null, string, …

Source
2

Sass builds a string

You get an unquoted string description of that value.

Compile
3

Print or peek

Use @debug (best) or temporary interpolation while learning.

Debug
4

Remove before shipping

Do not rely on the exact inspect string in production CSS.

⚠️ Common Pitfalls

  • Treating output as stable API — format can change between Sass versions.
  • Assuming valid CSS — maps and null strings are not design tokens.
  • Leaving peeks in production — strip debug custom properties before release.
  • Using inspect instead of map/list APIs — read values with map.get, not string parsing.
  • Expecting runtime inspection — browsers never evaluate meta.inspect.

💡 Best Practices

✅ Do

  • Use @use "sass:meta" and meta.inspect()
  • Prefer @debug meta.inspect(…) while coding
  • Inspect maps/lists that confuse you
  • Remove temporary CSS peeks before shipping
  • Treat the string as human-readable only

❌ Don’t

  • Parse inspect output to drive production styles
  • Depend on exact punctuation across Sass upgrades
  • Ship --debug tokens to users
  • Confuse it with CSS attr() or browser DevTools
  • Expect every result to be valid CSS

Key Takeaways

Knowledge Unlocked

Five things to remember about meta.inspect()

Stringify any Sass value for debugging—not for stable production CSS.

5
Core concepts
📦 02

Module

sass:meta

@use
📄 03

Returns

unquoted string

Result
🔎 04

Purpose

debugging

Use
05

Caution

format unstable

Safe

❓ Frequently Asked Questions

meta.inspect($value) returns an unquoted string representation of any Sass value—lists, maps, null, strings, numbers, and more—so you can see what Sass holds during compilation.
Not always. Official docs: inspect can represent values that cannot appear in CSS, so the string is not guaranteed to be valid CSS. Prefer it for @debug or temporary custom properties while learning.
No. Official heads-up: inspect is for debugging and its format is not guaranteed to stay the same across Sass versions or implementations. Do not build production CSS that depends on the exact string.
Simple interpolation or quoting may fail or look different for maps, null, and other Sass-only types. inspect is designed to stringify any Sass value for humans.
Yes. inspect($value) is the legacy global name. Prefer meta.inspect after @use "sass:meta".
Usually no. Use it while debugging with @debug or temporary tokens, then remove it from production CSS.
Did you know?

Official Sass docs show meta.inspect on a list, a map, null, and a quoted string in one block—exactly the cases where plain CSS cannot show you what Sass is thinking.

Conclusion

meta.inspect() returns an unquoted string describing any Sass value. Use it with @debug (or temporary peeks) while learning and troubleshooting—and remember the official warning: the format is for debugging, not a stable CSS contract.

Continue with meta.keywords() or the Sass introduction.

Next: extract keyword args

Learn meta.keywords() to turn named $args... into a map.

meta.keywords() →

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