Converts a JavaScript value to its corresponding Sass value for use in https://github.com/sass/node-sass.

Usage no npm install needed!

<script type="module">
  import theoryofnekomataToSassValue from 'https://cdn.skypack.dev/@theoryofnekomata/to-sass-value';



Converts a JavaScript value to its corresponding Sass value for use in @node-sass.


  • Some people who use Sass still struggle with the syntaxes of Sass elements (such as maps and functions).
  • You want to have more control over your Sass stylesheets, particularly on parts where you think will involve heavy back-and-forth JavaScript-Sass interaction.
  • You want to avoid declaring too many variables, functions, etc.
  • I'm inspired by SassyJSON and what Webpack can do.


Via NPM:

$ npm install --save @theoryofnekomata/to-sass-value


var toSassValue = require('@theoryofnekomata/to-sass-value');

var sassString = toSassValue('a'),
    sassList = [1, 2, 3, 4, 5],
    sassMap = { a: 'b', c: 'gdfg' };

// use it with node-sass however you want


It supports conversion of:

  • numbers + optional units (integers and floats)
  • strings
  • arrays
  • objects
  • colors
  • Booleans
  • null and undefined
  • dates (powered by Moment.js)

It does not support conversion of

  • functions (converts it to SassTypes.Null.NULL)
  • complex objects (such as recursive ones)


Sure thing! Just clone the repo.

to-sass-value uses Jasmine for unit tests, and ESLint to make sure code is written consistently (and implied it will run consistently as well).

  • Run npm install upon initial clone.
  • Run npm test and make sure all the tests pass and properly written.
  • Run npm run lint to ensure consistency of your code (make sure to install ESLint first).
  • Create PRs so that I can confirm and merge your contributions.

Please star the repo if you find it useful in your projects.


MIT. See LICENSE file for details.