Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sass-json-vars

> 编程语言
Open source

Import variables as JSON into Sass

295 stars0 likes0 views
WebsiteGitHub

About

Import variables as JSON into Sass

Sass JSON Vars

@import json data into Sass $variables.

Important: the latest version of sass-rails is locked in to Sass 3.2. This means that Sass maps are not available to sass-json-vars to parse nested objects.

Usage

bash
gem install sass-json-vars

After that reload rails server if you are on rails.

For projects using Sass >= 3.3

Place variables in a JSON file:

javascript
// variables.json
{
    "font-sans": "Helvetica, sans-serif",
    "colors": {
        "red": "#c33"
    }
}

Import the file in Sass to expose variable names:

scss
@import "variables.json"

body {
    color: map-get($colors, red);
    font: $font-sans;
}

Require sass-json-vars when compiling

bash
sass style.scss -r sass-json-vars

For projects using Sass <= 3.2

Place variables in a JSON file:

javascript
// variables.json
{
    "font-sans": "Helvetica, sans-serif",
    "colors-red": "#c33"
}

Import the file in Sass to expose variable names:

scss
@import "variables.json"

body {
    color: $colors-red;
    font: $font-sans;
}

Require sass-json-vars when compiling

bash
sass style.scss -r sass-json-vars

What about node-sass?

Take a look at node-sass-json-importer for a libsass variant of this project:

https://github.com/Updater/node-sass-json-importer

Issues· 13 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言