Skip to content

Menu

CSS Variable Extractor

Extract and export CSS custom properties

Runs entirely in your browserFrontendFree, no sign-up
Loading tool

01What is CSS Variable Extractor?

Design tokens tend to pile up. A stylesheet starts with ten custom properties in :root, then grows a dark theme, a few component overrides, and some names nobody remembers adding. This extractor reads the CSS you paste and lists every custom property declaration, the --name: value kind defined in the CSS Custom Properties for Cascading Variables spec. It doesn't use a regex to find them. The input goes through PostCSS, a real CSS parser, so comments are skipped, minified or one-line rules work, and a missing closing brace shows up as an error with a line number, like "CSS parse error on line 1: Unclosed block". You get a clear message instead of a half-filled table. For each declaration the Variable Details table shows the name, value, scope, usage count and line. Scope is the full path to the declaration, outermost first. A token inside a dark-mode media query reads as @media (prefers-color-scheme: dark) › :root. Declarations outside any rule show as (top level). Usages count every var(--name) reference anywhere in the input, including references inside other custom properties and ones with a fallback like var(--bg, white). The count is per name. If --brand-color is declared in :root and again in .dark, both rows show the same number. Rows with zero usages are tinted amber and counted as Unused in the toolbar, next to the Variables and Scopes totals. A short example. Paste :root { --space-1: 4px; --brand-color: #3b82f6; }, then .dark { --brand-color: #60a5fa; }, then .btn { color: var(--brand-color); }. You get three rows. --space-1 has 0 usages, and both --brand-color rows show 1. With Export as set to JSON, the output is space1 set to 4px and brandColor set to #60a5fa. That last value is the catch with duplicates. Export as offers CSS, JSON with camelCase keys, SCSS $variables, and a JavaScript ES module exporting cssVariables. CSS and SCSS keep every declaration in order. JSON and JS hold one value per key, so the last one wins, and the toolbar tells you how many names were affected. In SCSS, names starting with a digit get a v- prefix, so --2xl becomes $v-2xl. In JS, keys that aren't valid identifiers are quoted. Values are copied as written, so nested var() calls stay as strings and nothing is resolved. Usage counts only cover the text you pasted. Parsing and exporting happen in your browser tab, so a private design system stays on your machine.

Design-system maintainers and front-end engineers use it to audit custom properties and move them between CSS, Sass and CSS-in-JS. The tool runs entirely in your browser, so your data never leaves your device.

02How to use CSS Variable Extractor

  1. Paste your CSS into the Input CSS box, or load one of the examples
  2. Check the Variables, Scopes and Unused counts in the toolbar
  3. Review the Variable Details table for each value, scope, usage count and line
  4. Pick a format in Export as and read the Exported Variables panel
  5. Click Copy Export

03Worked examples

Input: :root { --space-1: 4px; --brand-color: #3b82f6; } .dark { --brand-color: #60a5fa; } .btn { color: var(--brand-color); } (Export as: JSON)
Result: { "space1": "4px", "brandColor": "#60a5fa" }
Keys are camelCased. A JSON key holds one value, so the later .dark value replaces the :root one.
Input: Same CSS (Export as: SCSS)
Result: $space-1: 4px; $brand-color: #3b82f6; $brand-color: #60a5fa;
Both declarations stay, in order.
Input: Same CSS (Export as: JavaScript)
Result: export const cssVariables = { space1: "4px", brandColor: "#60a5fa", };
Input: :root { --2xl: 24px; } (Export as: SCSS, then JavaScript)
Result: $v-2xl: 24px; export const cssVariables = { "2xl": "24px", };
SCSS gets a v- prefix and JS quotes the key, because neither allows a leading digit.
Input: @media (prefers-color-scheme: dark) { :root { --bg: #0f172a; } } /* --fake: 1 */ .a { background: var(--bg, white) }
Result: --bg | #0f172a | @media (prefers-color-scheme: dark) › :root | usages 1 | line 1
One table row, shown here as text. The commented-out --fake is ignored, and the fallback form still counts as a usage.
Input: .a { --x: 1px
Result: CSS parse error on line 1: Unclosed block
No table is shown until the brace is closed.

04Common use cases

  • Finding custom properties in an old design-system stylesheet that nothing references any more
  • Turning :root tokens into a JS object for a styled-components or Emotion theme
  • Porting a token set to SCSS for a project still built with Sass
  • Listing light and dark theme tokens side by side, with their media query scope, for documentation
  • Pulling component-scoped variables out of a .card block before a refactor
  • Checking a minified vendor stylesheet to see which tokens it exposes for overriding

05Tips

  • Unused only means unused in the pasted text. A token may still be referenced in another file, inline styles or JavaScript via getPropertyValue.
  • For themes, paste one scope at a time before exporting to JSON or JS, or the dark values will overwrite the light ones.
  • Paste the whole bundle rather than one file to get usage counts that mean something.
  • If you get a parse error, check the reported line for a missing brace. PostCSS stops there instead of guessing.

06Related concepts

CSS custom properties, Design tokens, SCSS variables, Theming, var() function.

Frequently Asked Questions

What is CSS Variable Extractor?

CSS Variable Extractor is a free, browser-based developer tool on AIDToolStack. Extract and export CSS custom properties It requires no installation or sign-up and works entirely in your browser.

Is CSS Variable Extractor free to use?

Yes. No sign-up, no fees and no usage cap.

Does CSS Variable Extractor store my data?

No. It runs in your browser; nothing is uploaded.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe